@contextmanager
def inside_transaction():
 savepoint = transaction.savepoint()
 try:
  (yield)
 except Exception:
  transaction.savepoint_rollback(savepoint)
  raise
 else:
  transaction.savepoint_commit(savepoint)

@ contextmanager def inside_transaction ( ) : savepoint = transaction . savepoint ( ) try : ( yield ) except Exception : transaction . savepoint_rollback ( savepoint ) raise else : transaction . savepoint_commit ( savepoint )
perform the database operations inside a transaction .