Show all missing columns when raising the missing error.
This commit is contained in:
parent
8238481262
commit
6cac1d5a25
1 changed files with 4 additions and 1 deletions
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue