Unverified Commit 81866ad6 authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

fix _create_sql_stmt


Signed-off-by: Sebastian Schüpbach's avatarSebastian Schüpbach <sebastian.schuepbach@unibas.ch>
parent 92233a85
Pipeline #16009 passed with stages
in 4 minutes and 37 seconds
......@@ -88,14 +88,13 @@ def _get_values_from_digital_object(msg):
def _create_sql_stmt(table_name, record, fields):
(db_fields, db_values) = [(dbField, record[dbField])
for dbField in fields
if dbField in record and record[dbField] is not None]
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_fields = ','.join(db_fields)
db_values = ','.join([str(db_value)
if isinstance(db_value, numbers.Number)
else "'{}'".format(db_value)
for db_value in db_values])
return 'INSERT IGNORE INTO {} ({}) VALUES ({})'.format(
table_name, db_fields, db_values)
......
Supports Markdown
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