Help › Work in notebooks

Run notebook cells on several connections

Run a notebook's cells on different connections, name their results, and join results from different databases in a scratch cell.

Querlyn 0.1.0 is not released yet. This help describes it ahead of release.

A notebook runs on its connection, the one in its toolbar, but each query cell may run on a connection of its own: orders from the shop's PostgreSQL in one cell, customers from the CRM's SQLite in the next. A scratch cell then joins their results, though they come from different servers.

Choose a cell's connection

The selected query cell shows where it runs at its top, beside its language. Click it for its menu:

  • The notebook's connection: the cell runs where the notebook does, and follows it when you change the notebook's connection.
  • One of your connections: the cell runs there. A Production connection is marked in the menu as in the sidebar.
  • Database: …: on a server with several databases, the cell runs in the one you choose.
  • Scratch: the cell becomes a scratch cell (see below).

A cell that runs elsewhere than the notebook says where at its top even when it is not selected. A new query cell runs where the selected one does. The same choices are commands too, in the Notebook menu and the command palette: Notebook › Run Cell on the Notebook's Connection and Notebook › Make Cell a Scratch Cell.

Each connection the notebook's cells use has one session for the notebook, so a temporary table or a transaction one cell makes is there for the next cell on the same connection, as in a query tab. Commit and Roll Back in the toolbar end the transaction of the selected cell's connection. Closing the notebook closes its sessions, and asks first about any open transaction.

Run cells on several connections

Notebook › Run All Cells runs every cell on its own connection, in order; the run stops at the first failure, as on one connection. Production asks once for the whole run: every statement of every cell is checked first, on its own connection, and the question names each cell that needs it and its connection ("Cell 4 on Shop production: UPDATE without WHERE on orders"). Nothing runs on any connection until you answer; Cancel runs none of the cells. A read-only connection refuses a run that would write on it before anything runs anywhere.

Join results in a scratch cell

A scratch cell runs on the scratch, Querlyn's own DuckDB database on this computer, and reads the results of the notebook's other cells by their names, as tables:

SELECT c.name, sum(o.total) AS spent
FROM orders_2026 o
JOIN cell_2 c ON c.id = o.customer_id
GROUP BY c.name

Before a scratch cell runs, each result it names is copied into the scratch, typed as the scratch types every copy, so decimals and timestamps stay exact. A result already copied from the same run of its cell is not copied again. Completion in a scratch cell knows the names and their columns. The copies are the notebook's: other notebooks and the scratch's own tables do not see them, and they go when the notebook closes. They are always kept in memory, never on disk, even when the scratch keeps its tables in a file (keep_tables in the settings file), so rows from a Production database do not reach your disk through a scratch cell. (A result handed to a Python cell passes through a private file for a moment.) Nor does the scratch write its work to temporary files: work larger than its share of the computer's memory stops with "out of memory".

When the result's cell runs in the same run as the scratch cell (with Run All, for example), the join reads the whole result: the cell reads on to its last row first, or, when its result was cut, its statement runs again on its connection to copy every row. The scratch cell says so under its result ("Every row of cell_1 (3,000 rows) was read first for this join"). This needs a statement that only reads, and stays within the scratch's copy limit and a tab's memory for results; on a connection that bills by the data a query reads, such as BigQuery, a statement is not run again by itself.

Otherwise, what is copied is what the cell holds: the rows its grid loaded, or the rows the file saved for it. When a cell holds only part of its result, the scratch cell says so under its result, and why a whole read was not possible. Load All (Notebook › Load All Rows of the Results Read) copies every row of those results, running their statements again on their connections (only statements that only read), and runs the scratch cell again.

Rows never go from one server to another: copies go into the scratch on this computer. A column that is masked, or marked sensitive where it came from, is copied empty, and the scratch cell says which under its result.

Name a result

Every query cell's result has a name scratch cells read it by: cell_3 for the third cell, unless you rename it. The selected cell shows its name at its top, beside its connection; click it, or choose Notebook › Name Cell Result…, to change it. A name is letters, digits and _, starting with a letter or _, and is the notebook's own: no two cells share one. The file keeps it, so a scratch cell still reads the same result when the notebook is opened again.

Notebooks from elsewhere

The file keeps each cell's connection as it keeps the notebook's: its name, engine, host and database, never a password. When the notebook is opened on another computer, a cell runs on the connection of that name there. A cell whose connection is not there says so at its top and runs nothing until you choose one; when one of your connections looks like it, Use offers it (Notebook › Use the Suggested Connection for the Cell). Querlyn never makes a connection from a notebook. See Open notebooks from others.

Help for Querlyn 0.1.0. All help topics