Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cloud-infrastructure
data-analytics
Commits
6d073c67
Commit
6d073c67
authored
May 02, 2021
by
Antonin Dvorak
Browse files
sqlite3 - remove the WITH statement for db conn
parent
e86b5551
Changes
1
Hide whitespace changes
Inline
Side-by-side
adcern/sqlite3_backend.py
View file @
6d073c67
...
...
@@ -17,25 +17,24 @@ def modify_db(conn,
"""
upperbound
=
11
with
conn
:
c
=
conn
.
cursor
()
# retry db execute
for
x
in
range
(
1
,
upperbound
):
try
:
if
args
:
c
.
execute
(
query
,
*
args
)
else
:
c
.
execute
(
query
)
except
Exception
as
e
:
print
(
"Sqlite3 execute unsuccessful, reason:
\"
%s
\"
\n
Retrying after %s sec...."
%
(
str
(
e
),
x
))
time
.
sleep
(
x
)
pass
c
=
conn
.
cursor
()
# retry db execute
for
x
in
range
(
1
,
upperbound
):
try
:
if
args
:
c
.
execute
(
query
,
*
args
)
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..."
)
c
.
execute
(
query
)
except
Exception
as
e
:
print
(
"Sqlite3 execute unsuccessful, reason:
\"
%s
\"
\n
Retrying after %s sec...."
%
(
str
(
e
),
x
))
time
.
sleep
(
x
)
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
for
x
in
range
(
1
,
upperbound
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment