Show all missing columns when raising the missing error.

This commit is contained in:
Ethan Dalool 2020-02-06 20:17:49 -08:00
parent 8238481262
commit 6cac1d5a25

View file

@ -48,13 +48,16 @@ def insert_filler(column_names, values, require_all=True):
cur.execute(query, bindings)
'''
values = values.copy()
missings = []
for column in column_names:
if column in values:
continue
if require_all:
raise ValueError('Missing column "%s"' % column)
missings.append(column)
else:
values[column] = None
if missings:
raise ValueError(f'Missing columns {missings}.')
qmarks = '?' * len(column_names)
qmarks = ', '.join(qmarks)
bindings = [values[column] for column in column_names]