|
|
@ -22,6 +22,7 @@ import os.path |
|
|
|
import re |
|
|
|
import threading |
|
|
|
import sqlite3 |
|
|
|
import time |
|
|
|
import sickbeard |
|
|
|
|
|
|
|
from sqlalchemy import create_engine, exc |
|
|
@ -102,7 +103,7 @@ class DBConnection: |
|
|
|
if "unable to open database file" in e.args[0] or "database is locked" in e.args[0]: |
|
|
|
logger.log(u"DB error: " + ex(e), logger.WARNING) |
|
|
|
attempt += 1 |
|
|
|
#time.sleep(cpu_presets[sickbeard.CPU_PRESET]) |
|
|
|
time.sleep(1) |
|
|
|
else: |
|
|
|
logger.log(u"DB error: " + ex(e), logger.ERROR) |
|
|
|
raise |
|
|
@ -126,17 +127,17 @@ class DBConnection: |
|
|
|
|
|
|
|
while attempt < 5: |
|
|
|
try: |
|
|
|
with self.connection as trans: |
|
|
|
for qu in querylist: |
|
|
|
if len(qu) == 1: |
|
|
|
if logTransaction: |
|
|
|
logger.log(qu[0], logger.DEBUG) |
|
|
|
sqlResult.append(trans.execute(qu[0])) |
|
|
|
elif len(qu) > 1: |
|
|
|
if logTransaction: |
|
|
|
logger.log(qu[0] + " with args " + str(qu[1]), logger.DEBUG) |
|
|
|
sqlResult.append(trans.execute(qu[0], qu[1])) |
|
|
|
|
|
|
|
for qu in querylist: |
|
|
|
if len(qu) == 1: |
|
|
|
if logTransaction: |
|
|
|
logger.log(qu[0], logger.DEBUG) |
|
|
|
sqlResult.append(self.connection.execute(qu[0])) |
|
|
|
elif len(qu) > 1: |
|
|
|
if logTransaction: |
|
|
|
logger.log(qu[0] + " with args " + str(qu[1]), logger.DEBUG) |
|
|
|
sqlResult.append(self.connection.execute(qu[0], qu[1])) |
|
|
|
|
|
|
|
self.connection.commit() |
|
|
|
logger.log(u"Transaction with " + str(len(querylist)) + u" queries executed", logger.DEBUG) |
|
|
|
return sqlResult |
|
|
|
except sqlite3.OperationalError, e: |
|
|
@ -146,6 +147,7 @@ class DBConnection: |
|
|
|
if "unable to open database file" in e.args[0] or "database is locked" in e.args[0]: |
|
|
|
logger.log(u"DB error: " + ex(e), logger.WARNING) |
|
|
|
attempt += 1 |
|
|
|
time.sleep(1) |
|
|
|
else: |
|
|
|
logger.log(u"DB error: " + ex(e), logger.ERROR) |
|
|
|
raise |
|
|
@ -182,7 +184,7 @@ class DBConnection: |
|
|
|
if "unable to open database file" in e.args[0] or "database is locked" in e.args[0]: |
|
|
|
logger.log(u"DB error: " + ex(e), logger.WARNING) |
|
|
|
attempt += 1 |
|
|
|
#time.sleep(cpu_presets[sickbeard.CPU_PRESET]) |
|
|
|
time.sleep(1) |
|
|
|
else: |
|
|
|
logger.log(u"DB error: " + ex(e), logger.ERROR) |
|
|
|
raise |
|
|
|