Skip to content

Add -o/--column-order option to insert and upsert - #847

Open
ChrisJr404 wants to merge 1 commit into
simonw:mainfrom
ChrisJr404:insert-column-order
Open

Add -o/--column-order option to insert and upsert#847
ChrisJr404 wants to merge 1 commit into
simonw:mainfrom
ChrisJr404:insert-column-order

Conversation

@ChrisJr404

@ChrisJr404 ChrisJr404 commented Aug 25, 2026

Copy link
Copy Markdown

Closes #474

insert and upsert build their table using the order of columns in the incoming data. This adds -o/--column-order so you can say which columns should come first, the same way sqlite-utils transform -o already works:

sqlite-utils insert dogs.db dogs dogs.csv --csv -o name -o age

You can pass it more than once. Columns you don't name keep their original order after the ones you do, and it only affects tables the command creates, so an existing table's column order is left alone. Under the hood it just passes column_order through to insert_all(), which already supported it.

Added tests covering both insert and upsert, plus a short docs section.


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

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.

Add an option for specifying column names when inserting CSV data

1 participant