feat: Funcionando

This commit is contained in:
2026-02-12 08:45:33 -07:00
parent a8e7af87dc
commit 0f94d1cc67
8 changed files with 314 additions and 10 deletions

31
backend/list_all_users.py Normal file
View File

@@ -0,0 +1,31 @@
"""Script para listar todos los usuarios"""
import asyncio
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
from sqlalchemy.orm import sessionmaker
from sqlalchemy import select
from app.models.user import User
import os
async def list_users():
database_url = os.getenv('DATABASE_URL', 'postgresql+asyncpg://postgres:postgres@db:5432/servicemanager')
engine = create_async_engine(database_url)
async_session = sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
async with async_session() as session:
result = await session.execute(select(User))
users = result.scalars().all()
if users:
print(f'Found {len(users)} users:')
for user in users:
print(f'\n Email: {user.email}')
print(f' Role: {user.role}')
print(f' Tenant ID: {user.tenant_id}')
print(f' User ID: {user.id}')
else:
print('No users found')
await engine.dispose()
if __name__ == "__main__":
asyncio.run(list_users())