Skip to content

Commit

Permalink
Move making queries to own page, refs #7
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jul 19, 2023
1 parent 20f0e18 commit 41916a7
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 54 deletions.
59 changes: 5 additions & 54 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ pip install dclient

### As a Datasette plugin

If you also have Datasette installed in the same environment it will register itself as a command plugin.

If you also have Datasette installed in the same environment it will register itself as a command plugin:
```bash
datasette install dclient
```
This means you can run any of these commands using `datasette client` instead, like this:
```bash
datasette client --help
Expand All @@ -29,65 +31,14 @@ You can install it into Datasette this way using:
```bash
datasette install dclient
```
## Running queries

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

```bash
dclient query https://latest.datasette.io/fixtures "select * from facetable limit 1"
```
Output:
```json
[
{
"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
<!-- [[[cog
import cog
from dclient import cli
from click.testing import CliRunner
runner = CliRunner()
result = runner.invoke(cli.cli, ["query", "--help"])
help = result.output.replace("Usage: cli", "Usage: dclient")
cog.out(
"```\n{}\n```".format(help)
)
]]] -->
```
Usage: dclient query [OPTIONS] URL 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.
```
<!-- [[[end]]] -->


## Contents

```{toctree}
---
maxdepth: 3
---
queries
aliases
authentication
```
51 changes: 51 additions & 0 deletions docs/queries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Running queries

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

```bash
dclient query https://latest.datasette.io/fixtures "select * from facetable limit 1"
```
Output:
```json
[
{
"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
<!-- [[[cog
import cog
from dclient import cli
from click.testing import CliRunner
runner = CliRunner()
result = runner.invoke(cli.cli, ["query", "--help"])
help = result.output.replace("Usage: cli", "Usage: dclient")
cog.out(
"```\n{}\n```".format(help)
)
]]] -->
```
Usage: dclient query [OPTIONS] URL 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.
```
<!-- [[[end]]] -->

0 comments on commit 41916a7

Please sign in to comment.