Unverified Commit 45a1b23a authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

replace rows instead of update

parent d933bd6c
Pipeline #21764 passed with stages
in 1 minute and 55 seconds
......@@ -43,14 +43,10 @@ class Indexer:
"""
db_values = [record[f] for f in fields if f in record and record[f]]
db_values.extend([record[f] for f in fields if f != 'sig' and f in record and record[f]])
db_fields = ','.join([f for f in fields if f in record and record[f]])
db_value_placeholders = ', '.join(['%s' for f in fields if f in record and record[f]])
key_value = ", ".join([f"{f}=%s" for f in fields
if f != 'sig' and f in record and record[f]])
# noinspection SqlNoDataSourceInspection
sql = 'INSERT INTO {} ({}) VALUES ({}) ON DUPLICATE KEY UPDATE {}'.format(
table_name, db_fields, db_value_placeholders, key_value)
logging.debug(sql)
sql = 'REPLACE INTO {} SET {}'.format(table_name, key_value)
return sql, tuple(db_values)
def insert_in_db(self, record) -> (bool, str):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment