mirror of
https://gitlab.cern.ch/wotsubo/PSBoardDataBase.git
synced 2025-06-11 07:19:23 +09:00
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:
commit
eba8d8f395
10 changed files with 1203 additions and 0 deletions
22
src/create_table.jl
Normal file
22
src/create_table.jl
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue