sqlite-utils/sqlite_utils
Charlie Tonneslan 33cab5e4ff insert: don't crash on header-only CSV with --detect-types
When the input has a header but no data rows, the insert path never
creates the table - the row loop has nothing to feed into the first
insert. The post-insert tracker.transform call then asserts the table
exists and blows up:

    AssertionError: Cannot transform a table that doesn't exist yet

Reported in #702 with the exact fix in the body. Guard the transform
on db[table].exists() so an empty CSV is just a no-op, matching what
--detect-types already does for a zero-byte CSV (no header either).

Closes #702.

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
2026-05-17 19:54:45 -04:00
..
__init__.py prepare_connection plugin hook 2023-07-22 15:59:08 -07:00
__main__.py Support 'python -m sqlite_utils', closes #368 2022-01-08 18:33:22 -08:00
cli.py insert: don't crash on header-only CSV with --detect-types 2026-05-17 19:54:45 -04:00
db.py Test against Python 3.15-dev, bump ty and Black (#738) 2026-05-17 16:52:48 -07:00
hookspecs.py More type annotations (#697) 2025-12-16 22:11:47 -08:00
plugins.py More type annotations (#697) 2025-12-16 22:11:47 -08:00
py.typed py.typed file so mypy picks up the types, closes #331 2021-11-14 15:21:04 -08:00
recipes.py More type annotations (#697) 2025-12-16 22:11:47 -08:00
utils.py Test against Python 3.15-dev, bump ty and Black (#738) 2026-05-17 16:52:48 -07:00