import asyncio

from sqlalchemy import text

from app.core.database import AsyncSessionLocal


async def main():
    try:
        async with AsyncSessionLocal() as session:
            configs = await session.execute(
                text(
                    "SELECT id, lab_id, open_time, close_time,"
                    " slot_duration_minutes, slot_capacity, operating_days"
                    " FROM lab_schedule_configs"
                )
            )
            rows = configs.fetchall()
            print("CONFIGS:", rows)
            slots = await session.execute(
                text(
                    "SELECT id, start_at, end_at, capacity, booked_count, deleted_at"
                    " FROM appointment_slots ORDER BY start_at ASC LIMIT 50"
                )
            )
            slot_rows = slots.fetchall()
            print("SLOTS COUNT (limit 50):", len(slot_rows))
            for s in slot_rows[:10]:
                print("  SLOT:", s)
    except Exception as e:
        print("DB ERROR:", e)


if __name__ == "__main__":
    asyncio.run(main())
