Query File Sessions
Query files are the best current CLI surface for multi-statement workflows.
One Primary Session
Section titled “One Primary Session”-- tonic-file: target=warehouse context.schema=public autocommit=off
update accounts set plan = 'pro' where id = 1;
select id, plan from accounts where id = 1;
commit;Run it:
tonic query exec --file account-upgrade.sqlAll three statements use the primary reusable session. With autocommit=off, ordinary statements participate in the same transaction until commit or rollback.
Separate Reader And Writer Handles
Section titled “Separate Reader And Writer Handles”-- tonic-bind: handle=writer target=warehouse context.schema=public autocommit=off-- tonic-bind: handle=reader target=warehouse context.schema=analytics autocommit=on
-- tonic: handle=writerupdate reports.job_state set last_run_at = current_timestamp where name = 'daily_sales';
-- tonic: handle=readerselect count(*) as rows_seen from daily_sales;
-- tonic: handle=writercommit;The writer and reader use separate reusable sessions because they have different handles and context.
One-Off Overrides
Section titled “One-Off Overrides”-- tonic-file: target=warehouse context.schema=analytics
select count(*) from daily_sales;
-- tonic: target=scratchselect sqlite_version();The second statement is ephemeral. It opens a one-off session and closes it immediately after execution.