-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdebug_script.py
More file actions
27 lines (24 loc) · 875 Bytes
/
debug_script.py
File metadata and controls
27 lines (24 loc) · 875 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
# debug_db.py
from app import create_app
from extensions import db
from sqlalchemy import text
app = create_app()
with app.app_context():
# Check if we can connect to the database
try:
# Updated for SQLAlchemy 2.x
with db.engine.connect() as conn:
result = conn.execute(text("SELECT 1"))
print("Database connection successful!")
except Exception as e:
print(f"Database connection failed: {e}")
# Check if tables exist
try:
from models.rule import Rule
# Updated for SQLAlchemy 2.x
from sqlalchemy import inspect
inspector = inspect(db.engine)
print(f"Tables in database: {inspector.get_table_names()}")
print(f"Rule table exists: {'rules' in inspector.get_table_names()}")
except Exception as e:
print(f"Error checking Rule table: {e}")