Rollback transaction on sql error

This commit is contained in:
Peter Stockings
2022-12-05 21:51:15 +11:00
parent c030ff4448
commit 87d7d9e9f4

3
db.py
View File

@@ -26,7 +26,10 @@ class DataBase():
if cur.description is not None:
rv = cur.fetchall()
if commit:
try:
self.conn.commit()
except:
self.conn.rollback()
cur.close()
return (rv[0] if rv else None) if one else rv