ATRIUMsearch → argument graph
Article · 2026-07-11 · 6 moments

sqlite-utils 4.1

Release: sqlite-utils 4.1 The first dot-release since 4.0 a few days ago, introducing a number of minor new features. sqlite-utils insert and sqlite-utils upsert now accept a --code option for providing a block of Python code (or a path to a .py file) that defines a rows() function or rows iterable of rows to insert, as an alternative to importing from a file. (#684) sqlite-utils already had features that allow you to pass blocks of Python code as CLI arguments, for example this one f ✦ AI generated

01
Example

sqlite-utils query can now read the SQL query from standard input by passing a hyphen in place of the query argument, enabling piped usage like echo "select * from dogs" | sqlite-utils query dogs.db -.

The query command gains stdin support, allowing SQL to be piped in rather than passed as a literal argument.

transcript

Simon Willison: sqlite-utils query can now read the SQL query from standard input by passing - in place of the query, for example echo "select * from dogs" | sqlite-utils query dogs.db -.

02
Fact

sqlite-utils upsert can now infer the primary key of an existing table, so the --pk flag can be omitted when upserting into a table that already has one defined.

Upsert no longer requires explicitly specifying --pk if the target table already has a primary key, closing a gap from the 4.0 Python API improvement.

transcript

Simon Willison: sqlite-utils upsert can now infer the primary key of an existing table, so --pk can be omitted when upserting into a table that already has a primary key. Another Codex suggestion, an obvious missing CLI feature from a Python library improvement that shipped in the 4.0 release.

03
Mechanism

table.transform()/table.transform_sql() and the sqlite-utils transform CLI command now accept strict=True/False or --strict/--no-strict to change a table's SQLite strict mode, since transform already copies data into a new table and can therefore switch strictness in either direction.

New strict-mode options were added to sqlite-utils' transform functionality, letting users switch a table from strict to non-strict or vice versa by leveraging the existing copy-based transform mechanism.

transcript

Simon Willison: That's exactly what the sqlite-utils transform mechanism does, so I extended it to add the ability to switch tables from strict to non-strict and vice-versa.

explains mechanism · 2

04
Example

The --code option lets you provide a block of Python code, or a path to a .py file, defining a rows() function or iterable that sqlite-utils insert/upsert uses to generate rows to insert, as an alternative to importing from a file.

sqlite-utils 4.1 adds a --code option to insert/upsert so users can define a rows() generator in Python directly on the command line instead of importing from a file.

transcript

Simon Willison: sqlite-utils insert and sqlite-utils upsert now accept a --code option for providing a block of Python code (or a path to a .py file) that defines a rows() function or rows iterable of rows to insert, as an alternative to importing from a file.

05
Fact

The new --type column-name type option for insert/upsert overrides the automatically chosen column type, which is useful for CSV/TSV columns like ZIP codes that look like integers but should be stored as TEXT to preserve leading zeros.

A long-requested feature now lets users force a column's type (e.g. TEXT for ZIP codes) rather than relying on automatic type inference during import.

transcript

Simon Willison: This is useful for CSV or TSV columns such as ZIP codes that look like integers but should be stored as TEXT to preserve leading zeros. A long-standing feature request which turned out to be a simple implementation.

06
Fact

There is no way to ALTER an existing SQLite table to make it strict; you have to copy the data out of the non-strict table into a new strict one.

Evan Hahn's post, which inspired the sqlite-utils strict-mode features, notes that SQLite offers no direct ALTER-based path to strict tables, requiring a data copy instead.

transcript

Evan Hahn: Unfortunately, I don't think there's a way to ALTER a table to make it strict. I think you have to copy the data out of the non-strict table into the strict one.

explains mechanism · 1

Highlight slides
Related episodes