1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-11-04 16:35:00 -05:00

Fix for scene_names table does not exist errors.

This commit is contained in:
echel0n 2014-06-03 23:52:55 -07:00
parent 37fceb2704
commit 7e91d3a600
2 changed files with 10 additions and 4 deletions

View File

@ -115,7 +115,7 @@ class DBConnection:
with db_lock:
# remove None types
querylist = [i for i in querylist if i!=None]
querylist = [i for i in querylist if i != None]
if querylist == None:
return
@ -125,7 +125,7 @@ class DBConnection:
# Transaction
self.connection.isolation_level = None
self.connection.execute('begin')
self.connection.execute('BEGIN')
while attempt < 5:
try:
@ -140,7 +140,7 @@ class DBConnection:
logger.log(qu[0] + " with args " + str(qu[1]), logger.DEBUG)
sqlResult.append(self.connection.execute(qu[0], qu[1]))
self.connection.execute('commit')
self.connection.execute('COMMIT')
logger.log(u"Transaction with " + str(len(querylist)) + u" queries executed", logger.DEBUG)
return sqlResult
@ -240,6 +240,9 @@ class DBConnection:
d[col[0]] = row[idx]
return d
def hasTable(self, tableName):
return len(self.action("SELECT 1 FROM sqlite_master WHERE name = ?;", (tableName, )).fetchall()) > 0
def sanityCheckDatabase(connection, sanity_check):
sanity_check(connection).check()

View File

@ -45,11 +45,14 @@ def retrieveNameFromCache(name):
Returns: the TVDB and TVRAGE id that resulted from the cache lookup or None if the show wasn't found in the cache
"""
cache_results = None
# standardize the name we're using to account for small differences in providers
name = sanitizeSceneName(name)
cacheDB = db.DBConnection('cache.db')
cache_results = cacheDB.select("SELECT * FROM scene_names WHERE name = ?", [name])
if cacheDB.hasTable('scene_names'):
cache_results = cacheDB.select("SELECT * FROM scene_names WHERE name = ?", [name])
if cache_results:
return int(cache_results[0]["indexer_id"])