mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-08-02 15:34:10 +02:00
Better error messages for --convert, closes #363
This commit is contained in:
parent
7d928f8308
commit
9dcb099905
2 changed files with 37 additions and 0 deletions
|
|
@ -1009,6 +1009,9 @@ def insert_upsert_implementation(
|
|||
if upsert:
|
||||
extra_kwargs["upsert"] = upsert
|
||||
|
||||
# docs should all be dictionaries
|
||||
docs = (verify_is_dict(doc) for doc in docs)
|
||||
|
||||
# Apply {"$base64": true, ...} decoding, if needed
|
||||
docs = (decode_base64_values(doc) for doc in docs)
|
||||
|
||||
|
|
@ -2760,6 +2763,14 @@ def json_binary(value):
|
|||
raise TypeError
|
||||
|
||||
|
||||
def verify_is_dict(doc):
|
||||
if not isinstance(doc, dict):
|
||||
raise click.ClickException(
|
||||
"Rows must all be dictionaries, got: {}".format(repr(doc)[:1000])
|
||||
)
|
||||
return doc
|
||||
|
||||
|
||||
def _load_extensions(db, load_extension):
|
||||
if load_extension:
|
||||
db.conn.enable_load_extension(True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue