"""SQLAlchemy implementation of Transaction Manager.""" from sqlalchemy.ext.asyncio import AsyncSession from app.application.interfaces import TransactionManager class SessionTransactionManager(TransactionManager): """SQLAlchemy Session-based Transaction Manager.""" def __init__(self, session: AsyncSession) -> None: self._session = session self._committed: bool = False async def commit(self) -> None: """Commit the current transaction.""" if not self._committed: await self._session.commit() self._committed = True async def rollback(self) -> None: """Rollback the current transaction.""" if not self._committed: await self._session.rollback()