import asyncio import os import sys # Ensure local imports work sys.path.append(os.getcwd()) from core.database import async_session_factory from sqlalchemy import select from models.ticket import Ticket from models.nexus_memory import NexusMemory async def test_mapper_init(): print("Testing SQLAlchemy Mapper Initialization...") async with async_session_factory() as db: try: # This will trigger mapper initialization stmt = select(Ticket).limit(1) await db.execute(stmt) print("OK: Ticket mapper initialized successfully.") stmt2 = select(NexusMemory).limit(1) await db.execute(stmt2) print("OK: NexusMemory mapper initialized successfully.") print("SUCCESS: ALL MAPPERS INITIALIZED SUCCESSFULLY.") except Exception as e: print(f"FAIL: Mapper Initialization FAILED!") print(f"Error Type: {type(e).__name__}") print(f"Error Message: {str(e)}") import traceback traceback.print_exc() if __name__ == "__main__": asyncio.run(test_mapper_init())