import asyncio
from sqlalchemy import text
from sqlalchemy.ext.asyncio import create_async_engine
DATABASE_URL = 'postgresql+asyncpg://scilit:scilit_prod_2026@postgres:5432/scilit'
async def main():
    engine = create_async_engine(DATABASE_URL)
    async with engine.connect() as conn:
        r = await conn.execute(text("SELECT column_name FROM information_schema.columns WHERE table_name = 'tenants' ORDER BY ordinal_position"))
        cols = [row.column_name for row in r]
        print('tenants cols:', cols)
        r = await conn.execute(text("SELECT column_name FROM information_schema.columns WHERE table_name = 'users' ORDER BY ordinal_position"))
        cols2 = [row.column_name for row in r]
        print('users cols:', cols2)
        # Get admin user
        r = await conn.execute(text("SELECT id, email FROM users WHERE email = 'admin@scilit.cn'"))
        u = r.first()
        print(f'admin user id: {u.id}')
        # List tenants
        r = await conn.execute(text("SELECT id, name FROM tenants"))
        for row in r:
            print(f'  tenant: {row.id} {row.name}')
    await engine.dispose()
asyncio.run(main())
