dclient/docs/aliases.md
Simon Willison 92c0d2a5ba Tests and docs for v2 introspection commands and alias features
Add test_commands_v2.py with 28 tests covering databases, tables,
plugins, schema, default_query, upsert, auth status, actor, and
get commands.

Add test_alias_v2.py with 5 tests for alias default, alias default-db,
and removing the default alias.

Update aliases.md and authentication.md docs for v2 API.

refs #29

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 15:21:58 -08:00

3.9 KiB

Aliases

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

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

You can list aliases with dclient alias list:

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

Once registered, you can pass an alias to commands using the -i flag:

dclient query fixtures "select * from news limit 1" -i latest

Default instance

Set a default instance so you don't need -i every time:

dclient alias default latest

Now commands will use latest automatically:

dclient databases
dclient tables -d fixtures

Default database

Set a default database for an alias:

dclient alias default-db latest fixtures

Now you can run bare SQL queries directly:

dclient "select * from facetable limit 5"

This uses the default instance and default database.

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 for a Datasette instance
  default     Set or show the default instance
  default-db  Set or show the default database for 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 for a Datasette instance

  Example usage:

      dclient alias add prod https://myapp.datasette.cloud

Options:
  --help  Show this message and exit.

dclient alias remove --help

Usage: dclient alias remove [OPTIONS] NAME

  Remove an alias

  Example usage:

      dclient alias remove prod

Options:
  --help  Show this message and exit.

dclient alias default --help

Usage: dclient alias default [OPTIONS] [NAME]

  Set or show the default instance

  Example usage:

      dclient alias default prod
      dclient alias default
      dclient alias default --clear

Options:
  --clear  Clear default instance
  --help   Show this message and exit.

dclient alias default-db --help

Usage: dclient alias default-db [OPTIONS] ALIAS_NAME [DB]

  Set or show the default database for an alias

  Example usage:

      dclient alias default-db prod main
      dclient alias default-db prod
      dclient alias default-db prod --clear

Options:
  --clear  Clear default database for this alias
  --help   Show this message and exit.