Spaces:
Paused

File size: 684 Bytes
4c985e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import sys
sys.path.append('.')

import asyncio
if sys.platform == 'win32':
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

from core.database import async_session_factory
from models.user import User
from models.user_workspace import UserWorkspace
from sqlalchemy import select

async def main():
    async with async_session_factory() as db:
        stmt = select(User.full_name, User.global_role, UserWorkspace.workspace_id, UserWorkspace.role).outerjoin(UserWorkspace, User.id == UserWorkspace.user_id)
        result = await db.execute(stmt)
        for row in result.all():
            print(row)

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