mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
parent
dc0a62556e
commit
607a2a9ff6
5 changed files with 45 additions and 67 deletions
|
|
@ -265,15 +265,15 @@ For tab-delimited data, use ``--tsv``::
|
|||
|
||||
$ sqlite-utils insert dogs.db dogs docs.tsv --tsv
|
||||
|
||||
Upserting data
|
||||
==============
|
||||
Insert-replacing data
|
||||
=====================
|
||||
|
||||
Upserting works exactly like inserting, with the exception that if your data has a primary key that matches an already exsting record that record will be replaced with the new data.
|
||||
Insert-replacing works exactly like inserting, with the exception that if your data has a primary key that matches an already exsting record that record will be replaced with the new data.
|
||||
|
||||
After running the above ``dogs.json`` example, try running this::
|
||||
|
||||
$ echo '{"id": 2, "name": "Pancakes", "age": 3}' | \
|
||||
sqlite-utils upsert dogs.db dogs - --pk=id
|
||||
sqlite-utils insert dogs.db dogs - --pk=id --replace
|
||||
|
||||
This will replace the record for id=2 (Pancakes) with a new record with an updated age.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue