mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-21 17:13:42 +00:00
Fix for sql rowcount error
This commit is contained in:
parent
8fbd9155d3
commit
f052848e52
1 changed files with 3 additions and 1 deletions
|
@ -204,6 +204,8 @@ class DBConnection:
|
||||||
|
|
||||||
def upsert(self, tableName, valueDict, keyDict):
|
def upsert(self, tableName, valueDict, keyDict):
|
||||||
|
|
||||||
|
changesBefore = self.connection.total_changes
|
||||||
|
|
||||||
genParams = lambda myDict: [x + " = ?" for x in myDict.keys()]
|
genParams = lambda myDict: [x + " = ?" for x in myDict.keys()]
|
||||||
|
|
||||||
query = "UPDATE " + tableName + " SET " + ", ".join(genParams(valueDict)) + " WHERE " + " AND ".join(
|
query = "UPDATE " + tableName + " SET " + ", ".join(genParams(valueDict)) + " WHERE " + " AND ".join(
|
||||||
|
@ -211,7 +213,7 @@ class DBConnection:
|
||||||
|
|
||||||
result = self.action(query, valueDict.values() + keyDict.values())
|
result = self.action(query, valueDict.values() + keyDict.values())
|
||||||
|
|
||||||
if result.rowcount > 0:
|
if self.connection.total_changes == changesBefore:
|
||||||
query = "INSERT INTO " + tableName + " (" + ", ".join(valueDict.keys() + keyDict.keys()) + ")" + \
|
query = "INSERT INTO " + tableName + " (" + ", ".join(valueDict.keys() + keyDict.keys()) + ")" + \
|
||||||
" VALUES (" + ", ".join(["?"] * len(valueDict.keys() + keyDict.keys())) + ")"
|
" VALUES (" + ", ".join(["?"] * len(valueDict.keys() + keyDict.keys())) + ")"
|
||||||
self.action(query, valueDict.values() + keyDict.values())
|
self.action(query, valueDict.values() + keyDict.values())
|
||||||
|
|
Loading…
Reference in a new issue