2022-11-22 01:57:06 +00:00
# dclient
2022-11-21 17:56:46 -08:00
2022-11-22 01:57:06 +00:00
[](https://pypi.org/project/dclient/)
[](https://github.com/simonw/dclient/releases)
[](https://github.com/simonw/dclient/actions?query=workflow%3ATest)
[](https://github.com/simonw/dclient/blob/master/LICENSE)
2022-11-21 17:56:46 -08:00
2022-11-21 21:38:14 -08:00
A client CLI utility for [Datasette ](https://datasette.io/ ) instances
2022-11-21 17:56:46 -08:00
2023-07-18 19:33:35 -07:00
## Things you can do with dclient
- Run SQL queries against Datasette and returning the results as JSON
- Run queries against authenticated Datasette instances
- Create aliases and store authentication tokens for convenient access to Datasette
- Insert data into Datasette using the [insert API ](https://docs.datasette.io/en/latest/json_api.html#the-json-write-api ) (Datasette 1.0 alpha or higher)
2022-11-22 01:57:06 +00:00
## Installation
2022-11-21 17:56:46 -08:00
2022-11-22 01:57:06 +00:00
Install this tool using `pip` :
2023-07-17 16:23:53 -07:00
```bash
2023-07-17 16:48:50 -07:00
pip install dclient
2023-07-17 16:23:53 -07:00
```
2023-07-17 16:48:50 -07:00
If you want to install it in the same virtual environment as Datasette (to use it as a plugin) you can instead run:
2023-07-17 16:23:53 -07:00
```bash
2023-07-17 16:48:50 -07:00
datasette install dclient
2023-07-17 16:23:53 -07:00
```
2023-07-17 16:48:50 -07:00
## Running a query
2023-07-17 16:23:53 -07:00
```bash
2023-07-17 16:48:50 -07:00
dclient query https://latest.datasette.io/fixtures "select * from facetable limit 1"
2022-11-21 19:00:20 -08:00
```
2023-07-17 16:48:50 -07:00
## Documentation
2022-11-21 19:00:20 -08:00
2023-07-17 16:48:50 -07:00
Visit * * [dclient.datasette.io ](https://dclient.datasette.io )** for full documentation on using this tool.
2022-11-21 18:53:12 -08:00
2022-11-22 01:57:06 +00:00
## Development
2022-11-21 17:56:46 -08:00
2022-11-22 01:57:06 +00:00
To contribute to this tool, first checkout the code. Then create a new virtual environment:
2023-07-17 16:48:50 -07:00
```bash
cd dclient
python -m venv venv
source venv/bin/activate
```
2022-11-22 01:57:06 +00:00
Now install the dependencies and test dependencies:
2023-07-17 16:48:50 -07:00
```bash
pip install -e '.[test]'
```
2022-11-22 01:57:06 +00:00
To run the tests:
2023-07-17 16:48:50 -07:00
```bash
pytest
```