new: create tables & add campaigns, runs, ps_boards, single run results

- currently, test automatically opens sqlitebrowser
- ext package is not well checked
This commit is contained in:
Wataru Otsubo 2024-09-12 20:26:38 +09:00 committed by qwjyh
commit eba8d8f395
10 changed files with 1203 additions and 0 deletions

22
src/create_table.jl Normal file
View file

@ -0,0 +1,22 @@
"""
create_database(dbpath::AbstractString)
Create new database at `dbpath` and prepare all tables.
"""
function create_database(dbpath::AbstractString)
db::SQLite.DB = DBInterface.connect(SQLite.DB, dbpath)
create_database(db)
end
function create_database(db::SQLite.DB)
dirpath = @__DIR__
sql_creates::String = read("$dirpath/sql/create_table.sql", String) |> chomp
delim = "CREATE "
for sql_create in eachsplit(sql_creates, delim, keepempty = false)
stmt = DBInterface.prepare(db, delim * sql_create)
DBInterface.execute(stmt)
end
db
end