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.

2 maanden geleden
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()