Skip to main content

A client CLI utility for Datasette instances

Project description

dclient

PyPI Changelog Tests License

A client CLI utility for Datasette instances

Installation

Install this tool using pip:

pip install dclient

If you want to install it in the same virtual environment as Datasette (to use it as a plugin) you can instead run:

datasette install dclient

Standalone v.s. plugin

Once installed you can use this tool like so:

dclient --help

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

This means you can run any of these commands using datasette client instead, like this:

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

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 SQL

  Run a SQL query against a Datasette database URL

  Returns a JSON array of objects

Options:
  --help  Show this message and exit.

Aliases

You can assign an alias to a Datasette database using the dclient alias command:

dclient alias add content https://datasette.io/content

You can list aliases with dclient alias list:

$ dclient alias list
content = https://datasette.io/content

Once registered, you can pass an alias to commands such as dclient query:

dclient query content "select * from news limit 1"

dclient alias --help

Usage: dclient alias [OPTIONS] COMMAND [ARGS]...

  Manage aliases for different instances

Options:
  --help  Show this message and exit.

Commands:
  add     Add an alias
  list    List aliases
  remove  Remove an alias

dclient alias list --help

Usage: dclient alias list [OPTIONS]

  List aliases

Options:
  --json  Output raw JSON
  --help  Show this message and exit.

dclient alias add --help

Usage: dclient alias add [OPTIONS] NAME URL

  Add an alias

Options:
  --help  Show this message and exit.

dclient alias remove --help

Usage: dclient alias remove [OPTIONS] NAME

  Remove an alias

Options:
  --help  Show this message and exit.

Development

To contribute to this tool, first checkout the code. Then create a new virtual environment:

cd dclient
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dclient-0.1a2.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

dclient-0.1a2-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file dclient-0.1a2.tar.gz.

File metadata

  • Download URL: dclient-0.1a2.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for dclient-0.1a2.tar.gz
Algorithm Hash digest
SHA256 e58339427feebd2844e9561faf0512ba55b8aa57449dce82d34a6817e3d1d76f
MD5 c62aee92a60f3204df57a7e202d69fc3
BLAKE2b-256 485084bec5bbfd298302064c7298f86194b9505f0596bb99319404042e779fe1

See more details on using hashes here.

File details

Details for the file dclient-0.1a2-py3-none-any.whl.

File metadata

  • Download URL: dclient-0.1a2-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for dclient-0.1a2-py3-none-any.whl
Algorithm Hash digest
SHA256 6378b5cff7e653cea5beffc5ddec64fb55706eb1934d4021fe409ce4a75a3be9
MD5 eabe375f55a269b0fe501dabac5084a7
BLAKE2b-256 fd8dbe7a8023932dcf372dafe373d386221a83847fa4da3c6fe09c22124f8919

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page