Skip to content

query

tonic query is the direct SQL execution surface.

Terminal window
tonic query ping --target warehouse

--target is required. The output includes the resolved target name, backend, and configured context.

Terminal window
tonic query exec \
--target warehouse \
--sql 'select * from reports.daily_sales'

Rules:

  • Exactly one of --sql or --file is required.
  • --target is required with --sql.
  • Inline SQL must contain exactly one statement after comments and whitespace are stripped.
  • Inline transaction-control statements are rejected.
  • Statement support and permissions are checked before a session opens.
Terminal window
tonic query exec --file reports.sql

--target is optional with --file; it acts as a fallback when the file does not declare a target with tonic-file.

Terminal window
tonic query exec --target warehouse --file reports.sql

File execution runs statements sequentially and stops on the first error.

Terminal window
tonic query exec \
--target warehouse \
--context schema=analytics \
--sql 'select count(*) from daily_sales'

Context keys are backend-aware. For example, Snowflake accepts database, schema, warehouse, and role; SQLite accepts none.

Terminal window
tonic query exec \
--target warehouse \
--autocommit off \
--sql 'update jobs set touched_at = current_timestamp where id = 1'

Valid values are on and off. The default is on.

For query files, --autocommit is the fallback for reusable sessions that do not declare autocommit in tonic-file or tonic-bind.

Terminal window
tonic query exec --target warehouse --format table --sql 'select 1'
tonic query exec --target warehouse --format csv --sql 'select 1'
tonic query exec --target warehouse --format json --sql 'select 1'

Command-like results render status, target, statement, and rows affected. Row-producing results render columns and rows.