Yujie Chen commited on
Commit
2803b34
·
1 Parent(s): df18812

Add common utilities for build

Browse files
Files changed (1) hide show
  1. common/seed_utils.py +13 -0
common/seed_utils.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json, sqlite3, pathlib
2
+
3
+ def load_json(path):
4
+ with open(path, "r", encoding="utf-8") as f:
5
+ return json.load(f)
6
+
7
+
8
+ def init_db(db_path, schema_sql_path):
9
+ db_path = pathlib.Path(db_path)
10
+ db_path.parent.mkdir(parents=True, exist_ok=True)
11
+ with sqlite3.connect(db_path) as con, open(schema_sql_path, "r", encoding="utf-8") as f:
12
+ con.executescript(f.read())
13
+ return str(db_path)