Skip to content

Add --extract to CLI insert and upsert - #909

Open
goingforstudying-ctrl wants to merge 1 commit into
simonw:mainfrom
goingforstudying-ctrl:cli-extract-20261017
Open

goingforstudying-ctrl wants to merge 1 commit into
simonw:mainfrom
goingforstudying-ctrl:cli-extract-20261017

Conversation

@goingforstudying-ctrl

@goingforstudying-ctrl goingforstudying-ctrl commented Oct 17, 2026 •

Copy link
Copy Markdown

Importing repeated values into lookup tables currently requires the Python API or a separate normalization step. Add repeatable --extract COLUMN options to insert and upsert, using the existing extracts= implementation and the interface prototyped in #352.

Each selected column uses a same-name lookup table with id and value columns. Repeated values reuse the same lookup ID, and nulls stay null. New target tables receive integer foreign keys; existing target schemas are preserved. CSV/TSV type inference continues for other columns and keeps extracted foreign keys as integers. Imports without the option retain their current behavior.

Includes usage examples, generated CLI help and coverage for JSON, newline JSON, CSV, TSV, --code, repeated extracts, batching, upserts, nulls, strict tables, type overrides, quoted identifiers, existing schemas and invalid input.

Validation: offline focused and full pytest suites, Black, Flake8, mypy, Cog and the added documentation section on Python 3.11.6 / SQLite 3.42.0. Other Python/SQLite versions and upstream CI have not been run for this change.

Refs #352.


📚 Documentation preview 📚: https://sqlite-utils--909.org.readthedocs.build/en/909/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant