Commit 5c7cfb2e authored by Antonin Dvorak's avatar Antonin Dvorak Committed by Domenico Giordano
Browse files

sqlite3 - retry also for execute part

parent 847218f7
import sqlite3
import sqlite3
def modify_db(conn,
query,
......@@ -16,12 +17,20 @@ def modify_db(conn,
args: array
additional arguments for execute query, optional
"""
with conn.cursor() as c:
if args:
c.execute(query,args)
else:
c.execute(query)
with conn.cursor() as c:
for x in range(0, 10):
try:
if args:
c.execute(query, args)
else:
c.execute(query)
except:
print("Sqlite3 execute unsuccessful, retrying....")
time.sleep(1)
pass
finally:
break
# retry commit - db might be locked by different process
for x in range(0, 10):
......@@ -32,5 +41,4 @@ def modify_db(conn,
time.sleep(1)
pass
finally:
break
\ No newline at end of file
break
\ No newline at end of file
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