Spaces:
Running

File size: 813 Bytes
e4d238f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import sys
import os

# Create absolute path to backend directory
BACKEND_DIR = os.path.dirname(os.path.abspath(__file__))
if BACKEND_DIR not in sys.path:
    sys.path.insert(0, BACKEND_DIR)

from sqlalchemy import text
from app.db.session import async_session_maker
from app.core.config import settings

async def list_tenants():
    async with async_session_maker() as session:
        result = await session.execute(text("SELECT id, name, business_name FROM tenants"))
        tenants = result.fetchall()
        print(f"Found {len(tenants)} tenants:")
        for t in tenants:
            print(f"ID: {t[0]} | Name: {t[1]} | Business: {t[2]}")

if __name__ == "__main__":
    if os.name == 'nt':
        asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
    asyncio.run(list_tenants())