Skip to content
This repository has been archived by the owner on May 2, 2018. It is now read-only.

Commit

Permalink
Tweaked mass_action function so that we can log the individual querie…
Browse files Browse the repository at this point in the history
…s if we wanted, by default we only log the amount of queries when completed. Should help with low powered devices when trying to do the work and log the work would cause some thrashing on the hdd.
  • Loading branch information
thezoggy committed Mar 29, 2013
1 parent c3b8528 commit 91c428a
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions sickbeard/db.py
Expand Up @@ -66,7 +66,7 @@ def checkDBVersion(self):
else:
return 0

def mass_action(self, querylist):
def mass_action(self, querylist, logTransaction=False):

with db_lock:

Expand All @@ -79,18 +79,16 @@ def mass_action(self, querylist):
while attempt < 5:
try:
for qu in querylist:
query = qu[0]
if len(qu) > 1:
args = qu[1]
else:
args = None
if args == None:
logger.log(query, logger.DEBUG)
sqlResult.append(self.connection.execute(query))
else:
logger.log(query + " with args " + str(args), logger.DEBUG)
sqlResult.append(self.connection.execute(query, args))
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" query's executed", logger.DEBUG)
return sqlResult
except sqlite3.OperationalError, e:
sqlResult = []
Expand Down

0 comments on commit 91c428a

Please sign in to comment.