Rollback failed transaction
This commit is contained in:
7
db.py
7
db.py
@@ -18,7 +18,12 @@ class DataBase():
|
|||||||
|
|
||||||
def execute(self, query, args=(), one=False, commit=False):
|
def execute(self, query, args=(), one=False, commit=False):
|
||||||
cur = self.conn.cursor(cursor_factory=RealDictCursor)
|
cur = self.conn.cursor(cursor_factory=RealDictCursor)
|
||||||
cur.execute(query, args)
|
try:
|
||||||
|
cur.execute(query, args)
|
||||||
|
except:
|
||||||
|
self.conn.rollback()
|
||||||
|
raise Exception('Rolling back transaction...')
|
||||||
|
|
||||||
rv = None
|
rv = None
|
||||||
if cur.description is not None:
|
if cur.description is not None:
|
||||||
rv = cur.fetchall()
|
rv = cur.fetchall()
|
||||||
|
|||||||
Reference in New Issue
Block a user