run transaction interactions now return a result

This commit is contained in:
Lex Berezhny 2018-12-15 15:38:58 -05:00
parent 390226d2ef
commit d72a152195

View file

@ -54,12 +54,13 @@ class AIOSQLite:
def __run_transaction(self, fun: Callable[[sqlite3.Connection, Any, Any], Any], *args, **kwargs):
self.connection.execute('begin')
try:
fun(self.connection, *args, **kwargs) # type: ignore
except (Exception, OSError):
result = fun(self.connection, *args, **kwargs) # type: ignore
self.connection.commit()
return result
except (Exception, OSError) as e:
log.exception('Error running transaction:', exc_info=e)
self.connection.rollback()
raise
else:
self.connection.commit()
def constraints_to_sql(constraints, joiner=' AND ', prepend_key=''):