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.
|
- from typing import AsyncGenerator
- from sqlalchemy.exc import SQLAlchemyError
- from sqlalchemy.ext.asyncio import AsyncSession
-
- from app.db.base import AsyncSessionLocal
-
-
- async def get_db_session() -> AsyncGenerator[AsyncSession, None]:
- async with AsyncSessionLocal() as session:
- try:
- yield session
- await session.commit()
- except SQLAlchemyError as e:
- await session.rollback()
- raise
- finally:
- await session.close()
|