Skip to content

Commit 95522ad

Browse files
committed
Clarified support for newline-delimited JSON, closes #417
1 parent 0b7b80b commit 95522ad

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

docs/cli.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,12 +805,21 @@ You can insert binary data into a BLOB column by first encoding it using base64
805805
Inserting newline-delimited JSON
806806
--------------------------------
807807

808-
You can also import newline-delimited JSON using the ``--nl`` option. Since `Datasette <https://datasette.io/>`__ can export newline-delimited JSON, you can combine the two tools like so::
808+
You can also import `newline-delimited JSON <http://ndjson.org/>`__ using the ``--nl`` option::
809+
810+
$ echo '{"id": 1, "name": "Cleo"}
811+
{"id": 2, "name": "Suna"}' | sqlite-utils insert creatures.db creatures - --nl
812+
813+
Newline-delimited JSON consists of full JSON objects separated by newlines.
814+
815+
If you are processing data using ``jq`` you can use the ``jq -c`` option to output valid newline-delimited JSON.
816+
817+
Since `Datasette <https://datasette.io/>`__ can export newline-delimited JSON, you can combine the Datasette and ``sqlite-utils`` like so::
809818

810819
$ curl -L "https://latest.datasette.io/fixtures/facetable.json?_shape=array&_nl=on" \
811820
| sqlite-utils insert nl-demo.db facetable - --pk=id --nl
812821

813-
This also means you pipe ``sqlite-utils`` together to easily create a new SQLite database file containing the results of a SQL query against another database::
822+
You can also pipe ``sqlite-utils`` together to create a new SQLite database file containing the results of a SQL query against another database::
814823

815824
$ sqlite-utils sf-trees.db \
816825
"select TreeID, qAddress, Latitude, Longitude from Street_Tree_List" --nl \

0 commit comments

Comments
 (0)