Skip to content
Wharfbase

SQL editor

SQL opens an editor with completion for the connection’s tables and columns.

  • Ctrl/⌘ Enter runs the statement under the cursor, Ctrl/⌘ Shift Enter the whole script. Results stream into a tab per statement; a script stops at its first error.
  • Cancel stops a running query on the database.
  • Explain shows the plan (PostgreSQL also runs EXPLAIN ANALYZE inside a transaction it rolls back).
  • History keeps your last 500 statements (7 days on Community); Saved queries can be shared with everyone.
  • Results stop at 1,000 rows per statement by default and at the server’s size cap, and say so.

Read-only means read-only here too:

  • PostgreSQL scripts run in a READ ONLY transaction, MySQL sessions are read-only, and SQLite files open read-only.
  • The editor reads comments the way the server does, so /*! … */ or nested comments can’t hide a write.
  • If a statement turns read-only mode off anyway, the script stops and is rolled back.
  • The editor refuses commands that could reach Wharfbase’s own files (SQLite ATTACH, MySQL LOAD DATA LOCAL) and Wharfbase’s own data folder.
  • A transaction a script leaves open is rolled back.

Every run is in the audit log, with the first 200 characters of the script.

Charts. The chart button next to a result’s row count draws the rows already fetched, without running the query again: bars, lines, areas, a scatter or a pie.

  • The first guess: dates along X make a line, anything else bars; the numeric columns are the values (columns named id are left out).
  • Choose: X, the value columns, Split by (one series per value of another column), and Stacked for bars and areas.
  • What it does with the rows: rows with the same X are added up. Past eight series the smallest are added up as “Other” (three for a scatter, six slices for a pie), and past 100 categories the rest are left out. The chart says so when it does.
  • Read the values by hovering, or with the arrow keys once the chart has focus. The table button shows them all.
  • Export saves the chart as PNG or SVG.
  • Saving: a query saved while its result is charted keeps the chart, and opens charted.

Parameters keep values out of the SQL text, for scripts: wb query pg17 'SELECT * FROM orders WHERE customer_id = $1' --params '[42]', or params in the API. They take the engine’s own placeholders: $1 (PostgreSQL, CockroachDB), ? (MySQL, MariaDB, SQLite), @p1 (SQL Server), :1 (Oracle), and work with a script of one statement. Values aren’t audited or kept in the history.