query
tonic query is the direct SQL execution surface.
tonic query ping --target warehouse--target is required. The output includes the resolved target name, backend, and configured context.
Execute Inline SQL
Section titled “Execute Inline SQL”tonic query exec \ --target warehouse \ --sql 'select * from reports.daily_sales'Rules:
- Exactly one of
--sqlor--fileis required. --targetis 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.
Execute A Query File
Section titled “Execute A Query File”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.
tonic query exec --target warehouse --file reports.sqlFile execution runs statements sequentially and stops on the first error.
Context Overrides
Section titled “Context Overrides”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.
Autocommit
Section titled “Autocommit”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.
Formats
Section titled “Formats”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.