The sqlly notebook CLI

функциональный

Run, validate, diff, export and inspect notebooks from a terminal or CI, with exit codes and a Git diff recipe.

sqlly-cli notebook runs a notebook without opening the app, against the connections you saved in SQLly. Use it from a terminal, a CI job, or a schedule: it checks notebooks before they run, compares two versions cell by cell for code review, keeps a history of runs and writes any recorded run as a report.

sqlly-cli ships inside the app, next to the app's own executable, and is usually not on your PATH. Put that folder on your PATH, or call the CLI by its full path, in the examples below (the Копировать команду CLI button in the backup, export and scheduled-task dialogs copies lines that already use the full path; notebooks don't have one). The CLI reads the same saved connections and keychain entries as the app, so it never asks for a password you already saved.

КомандаЧто оно делает
notebook runRuns the notebook, or part of it, records the run and exits with a code your script can act on.
notebook validateChecks the notebook without running anything: references, cycles, connections, unsafe cells, parameters and cell settings.
notebook diffCompares two notebook files cell by cell.
notebook catPrints a notebook as stable, readable text, for git diff.
notebook runsLists a notebook's recorded runs, shows one, or compares two.
notebook scheduleAdds, lists, removes and runs scheduled jobs. See Schedules and alerts.
notebook exportWrites a recorded run, or one of its dashboards, as HTML, PDF, Excel, Markdown, CSV, SVG or PNG.

Every command reads .sqllynb, older .sqlnb.json and Jupyter .ipynb files, and takes --format json (or the global --json) for a machine-readable envelope on stdout.

Run a notebook

sqlly-cli notebook run revenue.sqllynb \
  --param region=EMEA --param since=2026-01-01 \
  --connection warehouse="Storefront Prod"
  1. The file is checked first. Oversized or deeply nested files, connections that carry passwords and attachment paths that leave the notebook's folder are refused before the notebook is even parsed.
  2. Connections are mapped. A notebook names its connections by slot. Each slot maps to the saved connection whose id the notebook stores, or to the one you name with --connection slot=<name or id> (a notebook with one slot takes just the connection). A slot is never matched by its label alone.
  3. Trust is checked. The notebook must be trusted on this computer, as it will run. A notebook you made or trusted in the app is. For one from elsewhere, --trust trusts it for this run only and saves nothing. Mapping a slot to a different connection with --connection changes what the notebook runs on, so it needs trust for that mapping too.
  4. Cells run in dependency order, с {{name}} references folded in the same way the app does, and read-only cells run on a read-only copy of their connection.
  5. The run is recorded with its parameters (sensitive values hidden), each cell's outcome, check results and KPI values, and a summary prints. Kept results are stored encrypted with the same keychain key the app uses, and errors in the record have passwords a server echoed back masked.
--param name=value, --param-set file.json
Parameter values. A JSON file holds {"name": value, …}; --param wins over the file.
--cells
Which cells to run: name, a,b, name+ (it and everything downstream), ..name (the cells above it), name.. (it and below). Default: every cell.
--mode all|stale
stale reuses the outputs of the last recorded run whose fingerprints still match, and runs only the rest. It can only reuse outputs that were kept (see --retain).
--timeout
Per-cell timeout in seconds for cells that set none. Default 300; 0 means no limit.
--max-rows
Rows kept per cell output when the cell sets no limit. Default 10,000.
--retain
Output snapshots kept for this notebook, newest first. Default 20; 0 keeps none.
--allow-writes
Lets cells that change data run. Never on production connections, and never in a scheduled run.
--allow-production
Lets read-only cells run on connections marked production. Without it, any production cell refuses the run.
--fail-on assertion|error|never
When the exit code is non-zero. assertion (the default) fails on a cell error or a failed check, error only when a cell could not run, never always exits 0 once the run is recorded.
--dry-run
Prints the plan and the policy checks without running anything.
--out run.json
Also writes the run record and summary as JSON.

Exit codes

КодЗначение
0The run finished and nothing failed (or --fail-on never).
1A cell failed or was blocked.
2Usage error: a bad flag, file or parameter.
3Refused: the notebook is not trusted, a cell would change data, a production connection was not allowed, or the file scan rejected the file.
4A check (an assertion in a Tests cell) failed.
130Interrupted with Ctrl+C. The running query is cancelled and the remaining cells are recorded as canceled.

What the CLI runs

The CLI runs SQL cells, Tests cells, KPI cells (as the app writes them, with several tiles and a baseline cell) and data attachment cells. Chart, table and pivot cells don't need to run: they are recorded as not run and still appear in exports, drawn from their input's result. Profile, diff, plan, entity detail, AI, transform and formula cells, and picture attachments, are not run by the CLI yet. An attachment cell imports its CSV, Parquet, JSON, NDJSON or SQLite file into the notebook's local data: a file inside the notebook's folder always, a file elsewhere only when it was picked in the app on this computer, and never in a scheduled run. A SQL cell on the notebook's local data runs in the notebook's DuckDB workspace, with results from other connections copied in first, and only in a trusted notebook (a one-run --trust counts); see Local data with DuckDB.

Check a notebook in CI

sqlly-cli notebook validate revenue.sqllynb --format json

validate reports circular references (with the full chain and a suggested fix), references to cells that don't exist, invalid names, unknown or unsupported cell kinds, connection slots that are undeclared or not mapped on this machine, cells that change data, read-only cells whose SQL writes, production connections, references that can't be folded into SQL, cross-connection reads outside a local cell, invalid check or KPI settings, parameter errors, and the file scan's findings. It exits 1 when it finds errors. --strict treats warnings as errors; --require-connections fails when a slot isn't mapped (by default a CI machine without saved connections can still validate).

# .github/workflows/notebooks.yml (excerpt)
- name: Check notebooks
  run: |
    for f in notebooks/*.sqllynb; do
      sqlly-cli notebook validate "$f" --strict
    done

Review changes in Git

sqlly-cli notebook diff old.sqllynb new.sqllynb compares two notebooks by cell id: cells added, removed, moved or renamed, a unified line diff of each changed source, and changes to cell kinds, settings, safety policy, connections and parameters. Formatting-only churn is ignored. --context n sets the lines of context (default 3) and --exit-code exits 1 when the notebooks differ, like git diff --exit-code.

To make git diff и git difftool use it:

# .gitattributes
*.sqllynb diff=sqllynb

# once per machine (use the full path to sqlly-cli if it isn't on your PATH)
git config --global diff.sqllynb.textconv "sqlly-cli notebook cat"
git config --global difftool.sqllynb.cmd 'sqlly-cli notebook diff "$LOCAL" "$REMOTE"'

git diff -- report.sqllynb              # cells, parameters and connections instead of raw JSON
git difftool -t sqllynb -- report.sqllynb   # the semantic, cell-by-cell diff

sqlly-cli notebook diff --help prints this recipe too.

More on the file layout: File format and Git.

История запусков

sqlly-cli notebook runs revenue.sqllynb              # newest first, --limit 20 by default
sqlly-cli notebook runs show latest --notebook revenue.sqllynb
sqlly-cli notebook runs compare latest~1 latest --notebook revenue.sqllynb

A run is named by its id, an id prefix, latest или latest~N. runs compare says, cell by cell, whether a result changed because its SQL, its settings, its connection, its parameters or an input cell changed, or, when none of those did, whether the data itself changed (by row count or a checksum of the rows; "unchanged" only when both outputs were complete). It also lists parameter, connection, status, row count, check and KPI changes. The app's History tab reads the same records; see Run history and snapshots.

Export a run

sqlly-cli notebook export revenue.sqllynb --format pdf --out revenue.pdf \
  --run latest --template executive

Formats are html, pdf, xlsx, md, csv, svg и png; templates are executive, technical-incident, audit, financial и operational. --structure-only leaves every row and value out, --no-sql leaves SQL text out, --theme light|dark applies to PDF, SVG and PNG, and --force overwrites existing files. Sensitive values are always removed; when the export finds some, it stops until you pass --accept-redactions to acknowledge the warnings. After writing, it prints what the format could not show. See Exporting and the fidelity report.

sqlly-cli notebook export revenue.sqllynb --format pdf --out weekly.pdf   --dashboard "Weekly revenue" --page-per-section

--dashboard takes a dashboard's name (any letter case) or its layout cell's id and exports that dashboard with its sections and grid instead of the whole notebook; an unknown name lists the notebook's dashboards. --page-per-section starts each section on a new PDF page. A template keeps the dashboard's arrangement, as in the app. Every export, and every refused one, is written to the notebook's audit log.

Where runs are kept

Run records, output snapshots, schedules and their logs live in SQLly's notebook data folder (SQLLY/notebooks under your user data directory). Set SQLLY_NOTEBOOK_DATA_DIR to point the CLI somewhere else, for example a CI workspace. A notebook without a stored id (an older file, or a foreign .ipynb) gets a stable id from its file path, so its runs stay together.

Ограничения

  • The CLI output is English only; it is not translated like the app.
  • Only SQL, Tests, KPI and data attachment cells run headless (see above). A notebook that leans on transforms or formulas needs the app.
  • A SQL cell named like a table it reads (a cell called orders that selects FROM orders) turns into a self-referencing query when another cell folds it in, and some engines refuse that. Name the cell differently.