dclient/docs/queries.md
Simon Willison c847badc4e
dclient insert command (#13)
* Move making queries to own page, refs #7
* Documentation for the dclient insert feature, refs #8
* Implemented progress bar for insert, refs #8
* --pk option
* --ignore and --replace for insert, refs #8
* --batch-size option, refs #8
* First insert test, using a mock - refs #8
* insert test that exercises against an in-memory Datasette instance, refs #8
* Insert tests now cover an error case, refs #8
* Tests for --ignore and --replace, refs #8
* Tests for different formats, refs #8
* Test for --no-detect-types
* Support for --encoding, refs #8
2023-07-24 16:22:39 -07:00

1 KiB

Running queries

You can run SQL queries against a Datasette instance like this:

dclient query https://latest.datasette.io/fixtures "select * from facetable limit 1"

Output:

[
  {
    "pk": 1,
    "created": "2019-01-14 08:00:00",
    "planet_int": 1,
    "on_earth": 1,
    "state": "CA",
    "_city_id": 1,
    "_neighborhood": "Mission",
    "tags": "[\"tag1\", \"tag2\"]",
    "complex_array": "[{\"foo\": \"bar\"}]",
    "distinct_some_null": "one",
    "n": "n1"
  }
]

dclient query --help

Usage: dclient query [OPTIONS] URL_OR_ALIAS SQL

  Run a SQL query against a Datasette database URL

  Returns a JSON array of objects

Options:
  -t, --token TEXT  API token
  --help            Show this message and exit.