Skip to content

Commit 01bd097

Browse files
committed
cleanup
1 parent 2879840 commit 01bd097

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/SQLiteGraph.jl

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ using JSON3: JSON3
77
export DB, Node, Edge, find_nodes, find_edges
88

99
#-----------------------------------------------------------------------------# utils
10-
read_sql(fn::String) = read(joinpath(@__DIR__, "sql", fn), String)
11-
1210
function 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
10498
end

0 commit comments

Comments
 (0)