CoolFace
Apppublic

Ahmed-Raza/phase-3-backend

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
list_users.py22 linesDownload Raw Back to root
1from sqlalchemy import text
2from database import engine
3
4def list_all_users():
5    """List all users in the database"""
6    with engine.connect() as conn:
7        result = conn.execute(text('SELECT id, email, name, created_at FROM "user"'))
8        users = result.fetchall()
9        
10        if users:
11            print(f"\n๐Ÿ“‹ Found {len(users)} user(s):\n")
12            for user in users:
13                print(f"  ID: {user[0]}")
14                print(f"  Email: {user[1]}")
15                print(f"  Name: {user[2]}")
16                print(f"  Created: {user[3]}")
17                print("-" * 50)
18        else:
19            print("No users found in database.")
20
21if __name__ == "__main__":
22    list_all_users()
Ahmed-Raza/phase-3-backend ยท CoolFace