forked from LBRYCommunity/lbry-sdk
run transaction interactions now return a result
This commit is contained in:
parent
390226d2ef
commit
d72a152195
1 changed files with 5 additions and 4 deletions
|
@ -54,12 +54,13 @@ class AIOSQLite:
|
||||||
def __run_transaction(self, fun: Callable[[sqlite3.Connection, Any, Any], Any], *args, **kwargs):
|
def __run_transaction(self, fun: Callable[[sqlite3.Connection, Any, Any], Any], *args, **kwargs):
|
||||||
self.connection.execute('begin')
|
self.connection.execute('begin')
|
||||||
try:
|
try:
|
||||||
fun(self.connection, *args, **kwargs) # type: ignore
|
result = fun(self.connection, *args, **kwargs) # type: ignore
|
||||||
except (Exception, OSError):
|
self.connection.commit()
|
||||||
|
return result
|
||||||
|
except (Exception, OSError) as e:
|
||||||
|
log.exception('Error running transaction:', exc_info=e)
|
||||||
self.connection.rollback()
|
self.connection.rollback()
|
||||||
raise
|
raise
|
||||||
else:
|
|
||||||
self.connection.commit()
|
|
||||||
|
|
||||||
|
|
||||||
def constraints_to_sql(constraints, joiner=' AND ', prepend_key=''):
|
def constraints_to_sql(constraints, joiner=' AND ', prepend_key=''):
|
||||||
|
|
Loading…
Reference in a new issue