1
0
Fork 0

Update use of sqlhelpers.insert_filler.

This commit is contained in:
voussoir 2022-08-13 13:03:37 -07:00
parent 6647d3bdab
commit 29aeeb0614
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -58,8 +58,6 @@ CREATE INDEX IF NOT EXISTS index_items_type_time on items(type, time);
CREATE INDEX IF NOT EXISTS index_items_age_at_retrieval on items(retrieved - time); CREATE INDEX IF NOT EXISTS index_items_age_at_retrieval on items(retrieved - time);
COMMIT; COMMIT;
''' '''
COLUMNS = sqlhelpers.extract_table_column_map(DB_INIT)
ITEMS_COLUMNS = COLUMNS['items']
def init_db(): def init_db():
global sql global sql
@ -224,8 +222,8 @@ def insert_item(data):
'retrieved': retrieved, 'retrieved': retrieved,
} }
log.info('Inserting item %s.', id) log.info('Inserting item %s.', id)
(qmarks, bindings) = sqlhelpers.insert_filler(ITEMS_COLUMNS, row, require_all=True) (qmarks, bindings) = sqlhelpers.insert_filler(row)
query = f'INSERT INTO items VALUES({qmarks})' query = f'INSERT INTO items {qmarks}'
cur.execute(query, bindings) cur.execute(query, bindings)
log.loud('Inserted item %s.', id) log.loud('Inserted item %s.', id)
else: else: