-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_db.py
More file actions
48 lines (40 loc) · 1.38 KB
/
init_db.py
File metadata and controls
48 lines (40 loc) · 1.38 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from __future__ import annotations
import sqlite3
from ftp_batch.config.local_test_settings import LOCAL_DB_PATH
def init_db(db_path):
with sqlite3.connect(db_path) as conn:
conn.execute(
"""
create table if not exists rubi_ingest (
id integer primary key autoincrement,
source_file text not null,
line_number integer not null,
record_type text not null,
payload_json text not null,
created_at text not null default current_timestamp
)
"""
)
conn.execute(
"""
create table if not exists rupi_ingest (
id integer primary key autoincrement,
source_file text not null unique,
prefix text not null,
image_ts text not null,
matched_text_file text,
matched_text_ts text,
matched_diff_seconds integer,
output_remote_file text,
created_at text not null default current_timestamp,
updated_at text not null default current_timestamp
)
"""
)
conn.commit()
def main():
init_db(LOCAL_DB_PATH)
print(f"[INIT] SQLite schema created: {LOCAL_DB_PATH}")
return 0
if __name__ == "__main__":
raise SystemExit(main())