From c51bc175de263873c928904e6c22ba453854234c Mon Sep 17 00:00:00 2001 From: Bug Fixer Date: Fri, 6 Feb 2026 00:45:59 -0600 Subject: [PATCH] Fix: CSV insert with --detect-types crashes on header-only CSV When using --detect-types with a CSV file containing only a header row (and no data rows), the insert would fail with 'Cannot transform a table that doesn't exist yet' because the table is only created when rows are inserted. This fix adds an existence check before attempting to transform. Fixes #702 --- sqlite_utils/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlite_utils/cli.py b/sqlite_utils/cli.py index 9b9ee20e..7e6af6ca 100644 --- a/sqlite_utils/cli.py +++ b/sqlite_utils/cli.py @@ -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