The backend component to interface with the smart contract.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 2 mēnešiem
1234567891011121314151617
  1. from typing import AsyncGenerator
  2. from sqlalchemy.exc import SQLAlchemyError
  3. from sqlalchemy.ext.asyncio import AsyncSession
  4. from app.db.base import AsyncSessionLocal
  5. async def get_db_session() -> AsyncGenerator[AsyncSession, None]:
  6. async with AsyncSessionLocal() as session:
  7. try:
  8. yield session
  9. await session.commit()
  10. except SQLAlchemyError as e:
  11. await session.rollback()
  12. raise
  13. finally:
  14. await session.close()