mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -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()]
|
genParams = lambda myDict: ["{key} = ?".format(key=k) for k in myDict.keys()]
|
||||||
|
|
||||||
|
items = list(valueDict.values()) + list(keyDict.values())
|
||||||
self.action(
|
self.action(
|
||||||
"UPDATE {table} "
|
"UPDATE {table} "
|
||||||
"SET {params} "
|
"SET {params} "
|
||||||
"WHERE {conditions}".format(
|
"WHERE {conditions}".format(
|
||||||
table=tableName,
|
table=tableName,
|
||||||
params=", ".join(genParams(valueDict)),
|
params=", ".join(genParams(valueDict)),
|
||||||
conditions=" AND ".join(genParams(keyDict))),
|
conditions=" AND ".join(genParams(keyDict))
|
||||||
list(valueDict.values()) + list(keyDict.values())
|
),
|
||||||
|
items
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.connection.total_changes == changesBefore:
|
if self.connection.total_changes == changesBefore:
|
||||||
items = list(valueDict.values()) + list(keyDict.values())
|
|
||||||
self.action(
|
self.action(
|
||||||
"INSERT OR IGNORE INTO {table} ({columns}) "
|
"INSERT OR IGNORE INTO {table} ({columns}) "
|
||||||
"VALUES ({values})".format(
|
"VALUES ({values})".format(
|
||||||
table=tableName,
|
table=tableName,
|
||||||
columns=", ".join(map(text_type, items)),
|
columns=", ".join(map(text_type, valueDict.keys())),
|
||||||
values=", ".join(["?"] * len(items))
|
values=", ".join(["?"] * len(valueDict.values()))
|
||||||
),
|
),
|
||||||
items,
|
list(valueDict.values())
|
||||||
)
|
)
|
||||||
|
|
||||||
def tableInfo(self, tableName):
|
def tableInfo(self, tableName):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue