Replace aliases.json with config.json storing instances with default_database. Instance resolution: -i flag → config default → DATASETTE_URL. Database resolution: -d flag → instance default_database → DATASETTE_DATABASE. Token resolution: --token → auth.json by alias → auth.json by URL → DATASETTE_TOKEN. Add click-default-group dependency for bare SQL shortcut support. Add DCLIENT_CONFIG_DIR env var to override config directory. Rewrite query, insert, get, and actor commands for v2 API where instance is always -i flag. Add upsert command sharing insert implementation. Add databases, tables, schema, plugins commands. Add default_query hidden command for bare SQL shortcut. Add alias default, alias default-db subcommands. Add auth status subcommand. refs #29 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1.9 KiB
(environment-variables)=
Environment variables
dclient supports several environment variables for convenient access to Datasette instances.
DATASETTE_URL
Set this to the base URL of your Datasette instance. It is used as a fallback when no instance is specified via -i and no default instance is configured:
export DATASETTE_URL=https://my-instance.datasette.cloud
Then you can omit the -i flag:
dclient databases
dclient query data "select * from my_table limit 10"
Aliases and the -i flag always take priority over DATASETTE_URL.
DATASETTE_DATABASE
Set this to a default database name. It is used as a fallback when no database is specified via -d and the current instance has no default_database configured:
export DATASETTE_DATABASE=data
Then you can use the bare SQL shortcut:
dclient "select * from my_table limit 10"
DATASETTE_TOKEN
Set this to an API token:
export DATASETTE_TOKEN=dstok_abc123
The token will be used automatically for any request that doesn't have a more specific token configured.
The precedence order for tokens is:
--tokenCLI flag (highest priority)- Stored token from
auth.json(matched by alias name, then URL prefix) DATASETTE_TOKENenvironment variable (lowest priority)
DCLIENT_CONFIG_DIR
Override the config directory (default ~/.config/io.datasette.dclient or platform equivalent):
export DCLIENT_CONFIG_DIR=/path/to/config
This is useful for testing or running multiple configurations side by side.
Using them together
These variables work well together for quick access to a single instance:
export DATASETTE_URL=https://my-instance.datasette.cloud
export DATASETTE_DATABASE=data
export DATASETTE_TOKEN=dstok_abc123
# Query
dclient "select * from my_table"
# Insert
cat records.json | dclient insert data my_table - --json
# Check your actor identity
dclient actor