mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-03 18:03: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()
|
||||
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."""
|
||||
cursor = self._cursor()
|
||||
|
||||
try:
|
||||
if 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:
|
||||
cursor.close()
|
||||
|
||||
|
@ -165,7 +168,7 @@ class DBConnection(object):
|
|||
|
||||
return sqlResult
|
||||
|
||||
def action(self, query, args=None, fetchall=False):
|
||||
def action(self, query, args=None, fetchall=False, fetchone=False):
|
||||
|
||||
with db_lock:
|
||||
|
||||
|
@ -182,7 +185,7 @@ class DBConnection(object):
|
|||
else:
|
||||
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
|
||||
break
|
||||
|
@ -209,6 +212,15 @@ class DBConnection(object):
|
|||
|
||||
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):
|
||||
|
||||
changesBefore = self.connection.total_changes
|
||||
|
|
|
@ -3479,9 +3479,9 @@ class Home(MainHandler):
|
|||
|
||||
def plotDetails(self, show, season, episode):
|
||||
myDB = db.DBConnection()
|
||||
result = myDB.action(
|
||||
result = myDB.selectOne(
|
||||
"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.'
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue