42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
|
|
import sys
|
|
import os
|
|
from sqlalchemy import text, inspect
|
|
|
|
# Assume we run this from backend/ with PYTHONPATH=.
|
|
from core.database import CoreSessionLocal, core_engine as engine
|
|
|
|
def check_table():
|
|
inspector = inspect(engine)
|
|
schemas = inspector.get_schema_names()
|
|
print(f"Schemas found: {schemas}")
|
|
|
|
if 'a76' not in schemas:
|
|
print("Schema 'a76' does not exist!")
|
|
# return # Proceed anyway to check if table exists in public or other schemas?
|
|
|
|
# Check for table in a76 schema
|
|
try:
|
|
table_names = inspector.get_table_names(schema='a76')
|
|
print(f"Tables in 'a76': {table_names}")
|
|
|
|
if 'manifests' in table_names:
|
|
print("Table 'a76.manifests' exists.")
|
|
columns = [c['name'] for c in inspector.get_columns('manifests', schema='a76')]
|
|
print(f"Columns: {columns}")
|
|
|
|
# Try a simple count
|
|
try:
|
|
with CoreSessionLocal() as db:
|
|
result = db.execute(text("SELECT count(*) FROM a76.manifests"))
|
|
print(f"Count result: {result.scalar()}")
|
|
except Exception as e:
|
|
print(f"Error querying table: {e}")
|
|
else:
|
|
print("Table 'a76.manifests' DOES NOT exist in schema 'a76'.")
|
|
except Exception as e:
|
|
print(f"Error inspecting schema 'a76': {e}")
|
|
|
|
if __name__ == "__main__":
|
|
check_table()
|