feat(chalice): pg_client allow rollback on recreation
This commit is contained in:
parent
67cdd2cfd9
commit
3296c7a891
2 changed files with 7 additions and 2 deletions
|
|
@ -203,7 +203,7 @@ def process():
|
|||
logging.error(query)
|
||||
print("------------")
|
||||
logging.error(e)
|
||||
cur = cur.recreate()
|
||||
cur = cur.recreate(rollback=True)
|
||||
if len(notifications) > 0:
|
||||
cur.execute(
|
||||
cur.mogrify(f"""UPDATE public.Alerts
|
||||
|
|
|
|||
|
|
@ -136,7 +136,12 @@ class PostgresClient:
|
|||
and not self.unlimited_query:
|
||||
postgreSQL_pool.putconn(self.connection)
|
||||
|
||||
def recreate_cursor(self):
|
||||
def recreate_cursor(self, rollback=False):
|
||||
if rollback:
|
||||
try:
|
||||
self.connection.rollback()
|
||||
except Exception as error:
|
||||
logging.error("Error while rollbacking connection for recreation", error)
|
||||
try:
|
||||
self.cursor.close()
|
||||
except Exception as error:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue