python-dependency-injector
python-dependency-injector copied to clipboard
How to manage rollback when need to call two repository method from a service
Here suppose deposit updated successfully but user balance not updated because of error. in that case how to rollback
def status_change(self,id: int, entity: DepositUpdate) -> Deposit:
# first call the deposit repository
self._deposit_repository.update(id, entity)
# then call user repository to update balance
self._user_repository.update(id, amount)
Framework : FastAPI DB : postgres ORM : sqlalchemy