monitoring refactor
This commit is contained in:
@@ -102,6 +102,13 @@ def init_database(db_path: Path, run_id: str):
|
||||
db_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with sqlite3.connect(db_path) as con:
|
||||
cur = con.cursor()
|
||||
cur.execute("""
|
||||
CREATE TABLE IF NOT EXISTS parsing_runs (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
run_id TEXT NOT NULL UNIQUE,
|
||||
start_time TIMESTAMP NOT NULL
|
||||
)
|
||||
""")
|
||||
cur.execute("""
|
||||
CREATE TABLE IF NOT EXISTS products (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -111,7 +118,8 @@ def init_database(db_path: Path, run_id: str):
|
||||
price INTEGER NOT NULL,
|
||||
url TEXT,
|
||||
is_in_stock BOOLEAN,
|
||||
parsed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
parsed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (run_id) REFERENCES parsing_runs (run_id)
|
||||
)
|
||||
""")
|
||||
cur.execute("""
|
||||
@@ -120,7 +128,8 @@ def init_database(db_path: Path, run_id: str):
|
||||
run_id TEXT NOT NULL,
|
||||
timestamp TEXT NOT NULL,
|
||||
level TEXT NOT NULL,
|
||||
message TEXT NOT NULL
|
||||
message TEXT NOT NULL,
|
||||
FOREIGN KEY (run_id) REFERENCES parsing_runs (run_id)
|
||||
)
|
||||
""")
|
||||
con.commit()
|
||||
|
||||
Reference in New Issue
Block a user