mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-21 07:54:24 +02:00
fix(cli): skip transform when table missing after header-only CSV (fixes #702)
insert_upsert_implementation and memory multi-file import call Table.transform() after TypeTracker runs. For a CSV with only a header row, insert_all yields no rows and may not create the table; transform() then asserted. Only run transform when the table exists. Covers both the insert command path and the memory command path. Made-with: Cursor
This commit is contained in:
parent
8d74ffc932
commit
a6b3812fc7
2 changed files with 17 additions and 2 deletions
|
|
@ -1176,7 +1176,7 @@ def insert_upsert_implementation(
|
|||
)
|
||||
else:
|
||||
raise
|
||||
if tracker is not None:
|
||||
if tracker is not None and db[table].exists():
|
||||
db.table(table).transform(types=tracker.types)
|
||||
|
||||
# Clean up open file-like objects
|
||||
|
|
@ -2033,7 +2033,7 @@ def memory(
|
|||
rows = (_flatten(row) for row in rows)
|
||||
|
||||
db.table(file_table).insert_all(rows, alter=True)
|
||||
if tracker is not None:
|
||||
if tracker is not None and db[file_table].exists():
|
||||
db.table(file_table).transform(types=tracker.types)
|
||||
# Add convenient t / t1 / t2 views
|
||||
view_names = ["t{}".format(i + 1)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue