28 lines
799 B
Python
28 lines
799 B
Python
|
|
import asyncio
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Add backend directory to sys.path
|
|
sys.path.append(str(Path(__file__).parent.absolute()))
|
|
|
|
from app.database import AsyncSessionLocal
|
|
from app.models.user import User
|
|
from sqlalchemy import select, func
|
|
|
|
async def check_users():
|
|
async with AsyncSessionLocal() as session:
|
|
result = await session.execute(select(func.count(User.id)))
|
|
count = result.scalar()
|
|
print(f"User count: {count}")
|
|
|
|
if count > 0:
|
|
result = await session.execute(select(User.username, User.role).limit(5))
|
|
users = result.fetchall()
|
|
print("Existing users:")
|
|
for u in users:
|
|
print(f"- {u.username} ({u.role})")
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(check_users())
|