-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_db_v3.py
More file actions
30 lines (23 loc) · 1011 Bytes
/
update_db_v3.py
File metadata and controls
30 lines (23 loc) · 1011 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
from sqlalchemy import create_engine, text
import os
from dotenv import load_dotenv
load_dotenv()
# Database URL
DB_URL = os.getenv("DATABASE_URL", "postgresql://curator:curator_secret@127.0.0.1:5432/reddit_curator")
def migrate():
print(f"Connecting to database at {DB_URL}...")
try:
engine = create_engine(DB_URL)
print("Engine created.")
with engine.connect() as conn:
print("Connected successfully.")
with conn.begin() as trans:
# Set lock timeout to 5 seconds
conn.execute(text("SET LOCAL lock_timeout = '5s';"))
print("Adding reasoning column to tagged_results...")
conn.execute(text("ALTER TABLE tagged_results ADD COLUMN IF NOT EXISTS reasoning TEXT;"))
print("Migration v3 completed successfully.")
except Exception as e:
print(f"Migration failed: {e}")
if __name__ == "__main__":
migrate()