@@ -7,8 +7,6 @@ using JSON3: JSON3
77export DB, Node, Edge, find_nodes, find_edges
88
99# -----------------------------------------------------------------------------# utils
10- read_sql (fn:: String ) = read (joinpath (@__DIR__ , " sql" , fn), String)
11-
1210function single_result_execute (db, stmt, args... )
1311 ex = execute (db, stmt, args... )
1412 isempty (ex) ? nothing : values (first (ex))[1 ]
@@ -76,8 +74,8 @@ struct DB{T}
7674
7775 function DB (file:: String = " :memory:" , T:: Type = String)
7876 db = SQLite. DB (file)
79- SQLite. @register db SQLite. regexp
80- statements = [
77+ SQLite. @register db SQLite. regexp # regular expressions used in `find_nodes` & `find_edges`
78+ foreach (x -> execute (db, x), [
8179 " CREATE TABLE IF NOT EXISTS nodes (
8280 id INTEGER NOT NULL UNIQUE,
8381 props TEXT,
@@ -94,11 +92,7 @@ struct DB{T}
9492 );" ,
9593 " CREATE INDEX IF NOT EXISTS source_idx ON edges(source);" ,
9694 " CREATE INDEX IF NOT EXISTS target_idx ON edges(target);"
97- ]
98- # workaround because sqlite won't run multiple statements at once
99- map (statements) do x
100- execute (db, x)
101- end
95+ ])
10296 new {T} (db)
10397 end
10498end
0 commit comments