Unverified Commit 996e47cb authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

update db entry on duplicate key

parent 4aae69f7
Pipeline #17940 passed with stages
in 1 minute and 45 seconds
......@@ -186,14 +186,17 @@ def _get_record_id(graph) -> str:
def _create_sql_stmt(table_name, record, fields) -> str:
db_fields = [dbField for dbField in fields
if dbField in record and record[dbField] is not None]
db_values = ','.join([str(record[db_field])
if isinstance(record[db_field], numbers.Number)
else "'{}'".format(record[db_field])
for db_field in db_fields])
db_values = [str(record[db_field])
if isinstance(record[db_field], numbers.Number)
else "'{}'".format(record[db_field])
for db_field in db_fields]
key_value = \
", ".join([k + "='" + v + "'" for (k, v) in zip(db_fields, db_values) if k != 'sig'])
db_fields = ','.join(db_fields)
db_values = ','.join(db_values)
# noinspection SqlNoDataSourceInspection
return 'INSERT IGNORE INTO {} ({}) VALUES ({})'.format(
table_name, db_fields, db_values)
return 'INSERT INTO {} ({}) VALUES ({}) ON DUPLICATE KEY UPDATE {}'.format(
table_name, db_fields, db_values, key_value)
def _create_entities_entry(record, mariadb_cursor):
......
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