Help › Work with results

Query your results and join across connections

Copy any result, or a CSV, JSON, Parquet or Excel file, into the scratch and query it with SQL, joining results from different connections.

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

The scratch is a database of Querlyn's own, built on DuckDB. Copy a result into it, or open a file there, and it becomes a table you can query with plain SQL. A PostgreSQL result and a MySQL result copied into the scratch can be joined like any two tables.

Nothing in the scratch is ever written back to the databases its tables came from.

Where the scratch is

The scratch is the last entry of the connections in the sidebar, Scratch. Its tables are listed directly under it, each with where it came from: the connection, or the file. Rest the pointer on a table to see the statement it was copied with, when, and whether it holds every row.

The scratch works like a connection: open a query tab on it with File › New Scratch Query, and you get completion, Explain, charts, copying and export as anywhere else. Its environment is Local, the lowest risk.

By default the scratch lives in memory: its tables are gone when Querlyn quits, and when you disconnect the scratch. See Keep or clear the scratch.

Copy a result into the scratch

  1. With a result showing, choose Query… in the bar above the grid, or Query › Query This Result…, also in Query › Query This Result… and on the grid's context menu.
  2. Check the Table name. Querlyn suggests the table the result came from, or the first table its statement reads. A name the scratch already has gets _2; if you type one it has, the dialog says that table will be replaced.
  3. If a scratch tab is open, Query it in offers it; or choose A new scratch tab.
  4. Choose Copy and Query.

When the copy is done, the scratch tab shows SELECT * FROM the new table, ready to run. To copy without opening a tab, use Query › Add to Scratch As… instead.

While the rows are copied, a line above the grid says how many, with Cancel (Query › Cancel Copy to Scratch). A copy that is cancelled or fails leaves the scratch as it was. When it is done, the line says how many rows the table holds, with Query It.

When only part of the result was fetched

Results load as you scroll, so a large result may be only partly fetched. The dialog then asks which rows to copy:

ChoiceWhat is copied
Fetch every row first (runs the query again)Every row. The statement runs again on the tab's session, and its rows go straight into the scratch.
Use the … rows fetched so farThe rows you have, as they are.

Running the statement again is offered only for a statement that just reads, as for exporting all rows: the data may have changed since, and the tab waits until the copy is done. A table made from the rows fetched so far says so: in its tooltip in the sidebar, and above a scratch tab's editor, where it reads rows fetched so far.

Join results from different connections

Copy a result from each connection, then join them in a scratch tab:

SELECT c.name, count(o.id) AS orders, sum(o.total) AS spent
  FROM customers c
  JOIN orders o ON o.customer_id = c.id
 GROUP BY c.name
 ORDER BY spent DESC

Above a scratch tab's editor, Scratch tables lists every table of the scratch with where it came from. Click a table to put its name at the cursor; rest the pointer on it for the statement it was copied with.

The scratch speaks DuckDB's SQL: see Connect to DuckDB. Drop a table you no longer need with DROP TABLE in a scratch tab.

Open a file in the scratch

Choose File › Open File in Scratch…, or drag files onto Scratch in the sidebar. Each file becomes a table named after it:

FileHow it is read
CSV (.csv, .txt), TSV (.tsv)DuckDB's reader, which finds the delimiter, the header and the column types itself
JSON (.json), JSON Lines (.jsonl, .ndjson)DuckDB's reader
Parquet (.parquet)DuckDB's reader
Excel (.xlsx)The first worksheet, read by Querlyn; column types are taken from its first 1,000 rows

A file that cannot be read is not opened, and the message says what is wrong with it, often with the line or row. If a later cell of an Excel sheet does not fit the type its first rows gave the column, the file is not read and the message names the row; to choose the types yourself, use Import data from a file into the scratch instead.

Refresh a table from its source

Query › Refresh from Source copies a table again from where it came from, and replaces it: right-click the table in the sidebar, or use the refresh button next to it above a scratch tab's editor. It is also in Query › Refresh from Source.

  • A result's statement runs again on its connection, in the database it came from, on a session of its own (so it does not see a tab's temporary tables). Querlyn connects first if needed, and runs only a statement that just reads; the connection's own check runs before it, and a statement the connection would ask about is not run.
  • A file is read again.
  • If the refresh fails, the table is as it was.

A table made with SQL in a scratch tab has no source to refresh from, and neither has one whose connection was deleted or whose statement has query parameters (Querlyn never keeps their values).

What a copy keeps

Values arrive exactly. Each column gets the DuckDB type that holds its values:

  • Exact decimals stay exact decimals, with the source's precision and scale when it gives them.
  • Timestamps with a time zone keep their instant (DuckDB shows them in UTC); times keep their offset.
  • Arrays become lists, nested as deep as they are.
  • JSON stays JSON, binary data stays binary, UUIDs stay UUIDs, and empty values stay NULL.

Where DuckDB has no type for a value, the column holds its text instead, and the message after the copy says which column and why: a type DuckDB does not have (such as PostgreSQL's interval), a decimal that is NaN or has more than 38 digits, or an array that mixes kinds of values. DuckDB keeps time to the microsecond; finer fractions of a time or a timestamp with a zone are cut, and the message says so.

A copy may hold up to 1 GB of values, and a file opened in the scratch may be up to 1 GB; a larger one stops with a message and leaves the scratch as it was. copy_limit_mb in the settings file changes the limit.

Masked columns

While a result's columns are masked (screen-share mode, or a connection that always masks), copying it is refused, and the message names the masked columns: the scratch would show them unmasked. Leave those columns out of the statement, or turn screen-share mode off, and copy again. In screen-share mode a result of several connections with a Database column is not copied either, for the same reason: turn the mode off first.

A column marked sensitive where it came from stays marked in the scratch: its values are masked in scratch results whenever screen-share mode is on.

Keep or clear the scratch

Command Palette › Preferences: Keep Scratch Tables Between Sessions keeps the scratch in a file in Querlyn's data folder, so its tables are there the next time Querlyn starts. It takes effect the next time the scratch connects. The file holds copies of your data: treat it like the databases it came from. A notebook's copies of its cells' results are never put in the file: they stay in memory. Kept or not, the scratch does not write its work to temporary files: work larger than its share of the computer's memory stops with "out of memory".

Query › Clear Scratch… drops every table of the scratch, after asking. The databases the tables came from are not touched.

What you run in a scratch tab is not kept in the query history. A scratch tab saved as a saved query is saved without a connection.

Help for Querlyn 0.1.0. All help topics