Spaces:
Runtime error
Runtime error
| from sqlalchemy import text, inspect | |
| from database import engine | |
| def check_schema(): | |
| """Check if all required columns exist in the database""" | |
| inspector = inspect(engine) | |
| print("=== Checking service_providers table ===") | |
| try: | |
| columns = inspector.get_columns('service_providers') | |
| print(f"Found {len(columns)} columns:") | |
| for col in columns: | |
| print(f" - {col['name']}: {col['type']} (nullable: {col['nullable']})") | |
| except Exception as e: | |
| print(f"β Error checking service_providers: {e}") | |
| print("\n=== Checking customers table ===") | |
| try: | |
| columns = inspector.get_columns('customers') | |
| print(f"Found {len(columns)} columns:") | |
| for col in columns: | |
| print(f" - {col['name']}: {col['type']} (nullable: {col['nullable']})") | |
| except Exception as e: | |
| print(f"β Error checking customers: {e}") | |
| print("\n=== Testing a simple query ===") | |
| try: | |
| with engine.connect() as conn: | |
| result = conn.execute(text("SELECT COUNT(*) FROM service_providers")) | |
| count = result.scalar() | |
| print(f"β service_providers table exists and has {count} rows") | |
| except Exception as e: | |
| print(f"β Query failed: {e}") | |
| if __name__ == "__main__": | |
| check_schema() | |