Skip to content
m4bwav edited this page Dec 4, 2026 · 1 revision

Upsert

dw.py upsert writes the rows of a CSV or JSON file into a sqlite table by key. Added in 0.3.0.

python skills/datawright/scripts/dw.py upsert new.csv store.db --table items --key id [--json]
  • Creates the table on first use (TEXT columns, unique key) and adds columns that appear later.
  • Rows whose values did not change are left alone, so rerunning the same file reports inserted 0 updated 0 unchanged N.
  • Refuses duplicate or empty keys (exit 2): dedupe first, for example with dw.py diff.
  • Composite keys: --key region,id.

Exit codes: 0 ok, 2 usage or input error.

Clone this wiki locally