mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-14 10:36:52 -07:00
Fix near operational error in upsert
This commit is contained in:
parent
84338c76c6
commit
959e2c317e
1 changed files with 7 additions and 6 deletions
|
@ -173,26 +173,27 @@ class DBConnection(object):
|
|||
|
||||
genParams = lambda myDict: ["{key} = ?".format(key=k) for k in myDict.keys()]
|
||||
|
||||
items = list(valueDict.values()) + list(keyDict.values())
|
||||
self.action(
|
||||
"UPDATE {table} "
|
||||
"SET {params} "
|
||||
"WHERE {conditions}".format(
|
||||
table=tableName,
|
||||
params=", ".join(genParams(valueDict)),
|
||||
conditions=" AND ".join(genParams(keyDict))),
|
||||
list(valueDict.values()) + list(keyDict.values())
|
||||
conditions=" AND ".join(genParams(keyDict))
|
||||
),
|
||||
items
|
||||
)
|
||||
|
||||
if self.connection.total_changes == changesBefore:
|
||||
items = list(valueDict.values()) + list(keyDict.values())
|
||||
self.action(
|
||||
"INSERT OR IGNORE INTO {table} ({columns}) "
|
||||
"VALUES ({values})".format(
|
||||
table=tableName,
|
||||
columns=", ".join(map(text_type, items)),
|
||||
values=", ".join(["?"] * len(items))
|
||||
columns=", ".join(map(text_type, valueDict.keys())),
|
||||
values=", ".join(["?"] * len(valueDict.values()))
|
||||
),
|
||||
items,
|
||||
list(valueDict.values())
|
||||
)
|
||||
|
||||
def tableInfo(self, tableName):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue