-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck_db.py
More file actions
23 lines (19 loc) · 726 Bytes
/
check_db.py
File metadata and controls
23 lines (19 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
import sys
from sqlalchemy import create_engine, text
from dotenv import load_dotenv
load_dotenv()
db_url = os.getenv("DATABASE_URL")
if not db_url:
print("DATABASE_URL not found")
sys.exit(1)
engine = create_engine(db_url)
with engine.connect() as conn:
# Check columns in 'user' table
result = conn.execute(text("SELECT column_name FROM information_schema.columns WHERE table_name = 'user'"))
columns = [row[0] for row in result]
print(f"Columns in 'user' table: {columns}")
# Check if there are users with dodoCustomerId
result = conn.execute(text('SELECT id, email, "dodoCustomerId" FROM "user" LIMIT 5'))
users = result.fetchall()
print(f"Sample users: {users}")