File size: 820 Bytes
354f315
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
27
28
29
30
31
import asyncio
import sys
from pathlib import Path

BACKEND_ROOT = Path(__file__).resolve().parent.parent
if str(BACKEND_ROOT) not in sys.path:
    sys.path.insert(0, str(BACKEND_ROOT))

from sqlalchemy import select

from app.database import close_db, connect_db, get_session
from app.models import User


async def run():
    await connect_db()
    try:
        async with get_session() as session:
            users = (await session.execute(select(User))).scalars().all()
            print(f"Total users in DB: {len(users)}")
            for u in users:
                print(
                    f"User ID: {u.id}, Supabase UID: {u.supabase_uid}, Email: {u.email}, Role: {u.role}, Approved: {u.is_approved}"
                )
    finally:
        await close_db()


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