mirror of
https://gitlab.cern.ch/wotsubo/PSBoardDataBase.git
synced 2025-06-08 22:15:44 +09:00
31 lines
720 B
Julia
31 lines
720 B
Julia
"""
|
|
create_database(db)
|
|
|
|
Create new database at `dbpath` and prepare all tables.
|
|
Tables are empty.
|
|
"""
|
|
function create_database end
|
|
|
|
"""
|
|
create_database(dbpath::AbstractString)
|
|
"""
|
|
function create_database(dbpath::AbstractString)
|
|
db::SQLite.DB = DBInterface.connect(SQLite.DB, dbpath)
|
|
|
|
create_database(db)
|
|
end
|
|
|
|
"""
|
|
create_database(db::SQLite.DB)
|
|
"""
|
|
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
|