Skip to content

Saved Targets

A target is a named database connection stored in tonic config. Query, inspect, and service execution all start by resolving a target name from effective config.

This is a product boundary: tonic is not an ad hoc connection-string runner.

Targets are visible in every execution surface:

  • tonic query exec --target warehouse --sql 'select 1'
  • -- tonic-file: target=warehouse
  • -- tonic-bind: handle=writer target=warehouse autocommit=off
  • JSON-RPC requests with a target field

Current target backends are:

  • postgres
  • snowflake
  • sqlite
  • mysql

Each backend owns its connection options, default context keys, secret references, and inspect behavior.

Secrets are referenced from config, not stored directly in config.

Postgres, MySQL, and Snowflake password auth use environment-variable references such as password_env. Snowflake keypair auth can also reference private_key_passphrase_env.

SQLite does not use secrets.

Inline SQL requires --target.

Query files resolve targets in this order:

  1. Per-statement handle or target override.
  2. File-scoped tonic-file metadata.
  3. CLI --target fallback.
  4. Error when no target is available.

inspect and serve use the same target resolution and backend-opening code as query.