-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_db.py
More file actions
33 lines (24 loc) · 737 Bytes
/
init_db.py
File metadata and controls
33 lines (24 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
init_db.py
Run this FIRST. Reads schema.sql and creates the database with all tables.
Usage:
python init_db.py
"""
import sqlite3
import os
from config import DB_PATH, SCHEMA_PATH
def init_db():
if not os.path.exists(SCHEMA_PATH):
print(f"Error: Could not find schema.sql at {SCHEMA_PATH}")
return
with open(SCHEMA_PATH, "r") as f:
schema_sql = f.read()
conn = sqlite3.connect(DB_PATH)
conn.executescript(schema_sql)
conn.commit()
conn.close()
print(f"Database created at: {DB_PATH}")
print("Tables created: Patient, Cases, Scans, Iteration_steps, Conclusion_runs")
print("\nNext step: python scripts/load_patient.py")
if __name__ == "__main__":
init_db()