Commit graph

17 commits

Author SHA1 Message Date
Simon Willison
7b3a15027e Add instances command, improve error messages with actionable hints
Add "dclient instances" command to list known instances from config,
with --json support.

Improve "No instance specified" and "No database specified" error
messages to show the exact commands needed to fix the problem.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 15:25:57 -08:00
Simon Willison
742d46de05 v1 to v2 config migration with tests
Add _migrate_v1_to_v2() to convert aliases.json to config.json format.
Single-path-segment URLs are split into instance URL + default_database.
Auth keys are migrated from URLs to alias names. Original files are
backed up as .bak.

7 tests covering simple migration, no path segment, auth migration,
URL fallback for unmatched auth, skip if config exists, skip if no
aliases, and multi-path-segment URLs.

refs #29

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 15:22:05 -08:00
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
Simon Willison
3621f13263 v2 config system, CLI rewrite, and updated core commands
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>
2026-02-24 15:21:52 -08:00
Simon Willison
32124a0bf3 Support DATASETTE_URL and DATASETTE_TOKEN environment variables
Allow configuring a base Datasette instance URL and API token via
environment variables, so users can run commands like
`dclient query data "select ..."` without specifying a full URL each time.

DATASETTE_URL is combined with the argument as a path segment.
DATASETTE_TOKEN is used as a lowest-priority fallback for auth.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 22:10:59 -08:00
Simon Willison
ab3aaf26f3 Fixed asyncio pattern for tests 2026-02-23 21:43:23 -08:00
Simon Willison
adfa6cce14 insert --alter support, closes #23 2024-02-27 20:49:54 -08:00
Simon Willison
8c82f9a572 Rename 'datasette client' to 'datasette dt', closes #18
Refs https://github.com/simonw/datasette/issues/2153#issuecomment-1691763427
2024-02-25 11:10:53 -08:00
Simon Willison
59129824e3 Update for Datasette 1.0 alphas to pass tests 2024-02-23 19:56:56 -08:00
Simon Willison
c847badc4e
dclient insert command (#13)
* Move making queries to own page, refs #7
* Documentation for the dclient insert feature, refs #8
* Implemented progress bar for insert, refs #8
* --pk option
* --ignore and --replace for insert, refs #8
* --batch-size option, refs #8
* First insert test, using a mock - refs #8
* insert test that exercises against an in-memory Datasette instance, refs #8
* Insert tests now cover an error case, refs #8
* Tests for --ignore and --replace, refs #8
* Tests for different formats, refs #8
* Test for --no-detect-types
* Support for --encoding, refs #8
2023-07-24 16:22:39 -07:00
Simon Willison
8a205d81a3
dclient auth commands
Closes #3
2023-07-17 16:23:53 -07:00
Simon Willison
c0d25a7512 Fixed failing test 2023-07-17 14:59:34 -07:00
Simon Willison
2c9af739c2 Test for datasette plugin registration, refs #4 2022-11-21 22:31:48 -08:00
Simon Willison
ff3b64f425 alias remove command, alias list --json option - refs #2 2022-11-21 19:00:20 -08:00
Simon Willison
6bc35f46c2 dclient aliases command, closes #2 2022-11-21 18:53:12 -08:00
Simon Willison
1ecb6a02e8 Initial dclient query command, refs #1 2022-11-21 18:16:28 -08:00
simonw
56c4672f37 Initial library structure 2022-11-22 01:57:06 +00:00