mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-11 05:33:37 +00:00
Merge remote-tracking branch 'origin/dev'
This commit is contained in:
commit
5500e0b245
2 changed files with 18 additions and 6 deletions
|
@ -79,14 +79,17 @@ class DBConnection(object):
|
||||||
if self.connection is None: self.reconnect()
|
if self.connection is None: self.reconnect()
|
||||||
return self.connection.cursor()
|
return self.connection.cursor()
|
||||||
|
|
||||||
def execute(self, query, args=None, fetchall=False):
|
def execute(self, query, args=None, fetchall=False, fetchone=False):
|
||||||
"""Executes the given query, returning the lastrowid from the query."""
|
"""Executes the given query, returning the lastrowid from the query."""
|
||||||
cursor = self._cursor()
|
cursor = self._cursor()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if fetchall:
|
if fetchall:
|
||||||
return self._execute(cursor, query, args).fetchall()
|
return self._execute(cursor, query, args).fetchall()
|
||||||
return self._execute(cursor, query, args)
|
elif fetchone:
|
||||||
|
return self._execute(cursor, query, args).fetchone()
|
||||||
|
else:
|
||||||
|
return self._execute(cursor, query, args)
|
||||||
finally:
|
finally:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
|
||||||
|
@ -165,7 +168,7 @@ class DBConnection(object):
|
||||||
|
|
||||||
return sqlResult
|
return sqlResult
|
||||||
|
|
||||||
def action(self, query, args=None, fetchall=False):
|
def action(self, query, args=None, fetchall=False, fetchone=False):
|
||||||
|
|
||||||
with db_lock:
|
with db_lock:
|
||||||
|
|
||||||
|
@ -182,7 +185,7 @@ class DBConnection(object):
|
||||||
else:
|
else:
|
||||||
logger.log(self.filename + ": " + query + " with args " + str(args), logger.DB)
|
logger.log(self.filename + ": " + query + " with args " + str(args), logger.DB)
|
||||||
|
|
||||||
sqlResult = self.execute(query, args, fetchall=fetchall)
|
sqlResult = self.execute(query, args, fetchall=fetchall, fetchone=fetchone)
|
||||||
|
|
||||||
# get out of the connection attempt loop since we were successful
|
# get out of the connection attempt loop since we were successful
|
||||||
break
|
break
|
||||||
|
@ -209,6 +212,15 @@ class DBConnection(object):
|
||||||
|
|
||||||
return sqlResults
|
return sqlResults
|
||||||
|
|
||||||
|
def selectOne(self, query, args=None):
|
||||||
|
|
||||||
|
sqlResults = self.action(query, args, fetchone=True)
|
||||||
|
|
||||||
|
if sqlResults == None:
|
||||||
|
return []
|
||||||
|
|
||||||
|
return sqlResults
|
||||||
|
|
||||||
def upsert(self, tableName, valueDict, keyDict):
|
def upsert(self, tableName, valueDict, keyDict):
|
||||||
|
|
||||||
changesBefore = self.connection.total_changes
|
changesBefore = self.connection.total_changes
|
||||||
|
|
|
@ -3479,9 +3479,9 @@ class Home(MainHandler):
|
||||||
|
|
||||||
def plotDetails(self, show, season, episode):
|
def plotDetails(self, show, season, episode):
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
result = myDB.action(
|
result = myDB.selectOne(
|
||||||
"SELECT description FROM tv_episodes WHERE showid = ? AND season = ? AND episode = ?",
|
"SELECT description FROM tv_episodes WHERE showid = ? AND season = ? AND episode = ?",
|
||||||
(int(show), int(season), int(episode))).fetchone()
|
(int(show), int(season), int(episode)))
|
||||||
return result['description'] if result else 'Episode not found.'
|
return result['description'] if result else 'Episode not found.'
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue