|
1234567891011121314151617 |
- from sqlalchemy.ext.asyncio import AsyncSession
-
- from sqlalchemy import insert, select
-
- from app.models.user import user
-
-
- async def add_user(session: AsyncSession, user_data: dict):
- stmt = insert(user).values(**user_data)
- await session.execute(stmt)
-
- async def get_user(session: AsyncSession, session_id: str):
- stmt = select(user).where(user.c.session_id == session_id)
- result = await session.execute(stmt)
- if result:
- return result.first()
- return None
|