From 225cf7299f0a9ef7c37caac656a8e0d8731c6cad Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sun, 27 Jan 2019 18:28:02 -0800 Subject: [PATCH] Docs example chaining --nl together --- docs/cli.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/cli.rst b/docs/cli.rst index 14f491e..305051a 100644 --- a/docs/cli.rst +++ b/docs/cli.rst @@ -128,6 +128,20 @@ You can also import newline-delimited JSON using the ``--nl`` option. Since `Dat $ curl -L "https://latest.datasette.io/fixtures/facetable.json?_shape=array&_nl=on" \ | sqlite-utils insert nl-demo.db facetable - --pk=id --nl +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:: + + $ sqlite-utils json sf-trees.db \ + "select TreeID, qAddress, Latitude, Longitude from Street_Tree_List" --nl \ + | sqlite-utils insert saved.db trees - --nl + # This creates saved.db with a single table called trees: + $ sqlite-utils csv saved.db "select * from trees limit 5" + TreeID,qAddress,Latitude,Longitude + 141565,501X Baker St,37.7759676911831,-122.441396661871 + 232565,940 Elizabeth St,37.7517102172731,-122.441498017841 + 119263,495X Lakeshore Dr,, + 207368,920 Kirkham St,37.760210314285,-122.47073935813 + 188702,1501 Evans Ave,37.7422086702947,-122.387293152263 + Upserting data ==============