The backend component to interface with the smart contract.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- 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()
|