Commit 6d073c67 authored by Antonin Dvorak's avatar Antonin Dvorak
Browse files

sqlite3 - remove the WITH statement for db conn

parent e86b5551
...@@ -17,25 +17,24 @@ def modify_db(conn, ...@@ -17,25 +17,24 @@ def modify_db(conn,
""" """
upperbound = 11 upperbound = 11
with conn: c = conn.cursor()
c = conn.cursor() # retry db execute
# retry db execute for x in range(1, upperbound):
for x in range(1, upperbound): try:
try: if args:
if args: c.execute(query, *args)
c.execute(query, *args)
else:
c.execute(query)
except Exception as e:
print("Sqlite3 execute unsuccessful, reason: \"%s\" \nRetrying after %s sec...." % (str(e), x))
time.sleep(x)
pass
else: else:
print("Sqlite3 execute successful, breaking the retry cycle.") c.execute(query)
break except Exception as e:
# max attempts achieved, quit print("Sqlite3 execute unsuccessful, reason: \"%s\" \nRetrying after %s sec...." % (str(e), x))
if x == upperbound - 1: time.sleep(x)
raise Exception("Sqlite3 - achieved max retries to execute with no success, giving up...") pass
else:
print("Sqlite3 execute successful, breaking the retry cycle.")
break
# max attempts achieved, quit
if x == upperbound - 1:
raise Exception("Sqlite3 - achieved max retries to execute with no success, giving up...")
# retry db commit # retry db commit
for x in range(1, upperbound): for x in range(1, upperbound):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment