The backend component to interface with the smart contract.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

2 个月前
1234567891011121314151617
  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