CoolFace
Apppublic

malepati/custom_template_working

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
simulate_api.py41 linesDownload Raw Back to root
1import sys2import os3sys.path.append(os.path.join(os.getcwd(), "servers", "fastapi"))4 5import asyncio6import json7from uuid import UUID8from sqlalchemy import select9from services.database import get_async_session, get_container_db_async_session10from models.sql.presentation_layout_code import PresentationLayoutCodeModel11from models.sql.template import TemplateModel12 13async def simulate_fetch(pid_str):14    pid = UUID(pid_str)15    print(f"--- FETCHING FOR {pid} ---")16    17    # Try primary DB18    print("Checking Primary DB (fastapi.db)...")19    async for session in get_async_session():20        stmt = select(PresentationLayoutCodeModel).where(PresentationLayoutCodeModel.presentation == pid)21        res = await session.execute(stmt)22        layouts = res.scalars().all()23        print(f"Found in primary: {len(layouts)}")24        for l in layouts:25            print(f" - Layout ID: {l.layout_id}")26            27    # Try container DB28    print("\nChecking Container DB (container.db)...")29    async for session in get_container_db_async_session():30        # Need to check if table exists first because model might not be bound to this engine31        try:32            stmt = select(PresentationLayoutCodeModel).where(PresentationLayoutCodeModel.presentation == pid)33            res = await session.execute(stmt)34            layouts = res.scalars().all()35            print(f"Found in container: {len(layouts)}")36        except Exception as e:37            print(f"Error checking container DB: {e}")38 39if __name__ == "__main__":40    asyncio.run(simulate_fetch("0e56f149-122d-4a02-a5b9-c8046b453c59"))41