The backend component to interface with the smart contract.
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
485 B

  1. from sqlalchemy.ext.asyncio import AsyncSession
  2. from sqlalchemy import insert, select
  3. from app.models.user import user
  4. async def add_user(session: AsyncSession, user_data: dict):
  5. stmt = insert(user).values(**user_data)
  6. await session.execute(stmt)
  7. async def get_user(session: AsyncSession, session_id: str):
  8. stmt = select(user).where(user.c.session_id == session_id)
  9. result = await session.execute(stmt)
  10. if result:
  11. return result.first()
  12. return None