import sys import os import logging logging.basicConfig(level=logging.INFO) sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), 'company-explorer'))) from backend.database import SessionLocal, Company def check_db_content(): db = SessionLocal() try: print("--- Checking content of 'companies' table ---") companies = db.query(Company).limit(5).all() if not companies: print("!!! FATAL: The 'companies' table is EMPTY.") # Let's check if the table is there at all try: count = db.query(Company).count() print(f"Row count is confirmed to be {count}.") except Exception as e: print(f"!!! Could not even count rows. The table might be corrupt. Error: {e}") else: print(f"Found {len(companies)} companies. Data seems to be present.") for company in companies: print(f" - ID: {company.id}, Name: {company.name}") finally: db.close() if __name__ == "__main__": check_db_content()