Differences from psql

View as Markdown

-c, -f, -t, -A and -x mean what they mean in psql, so this prints a bare number in either program:

hsql -tAc "select count(*) from orders"

It prints it the same way against every adapter, which is the part psql cannot do.

What Is Different

psqlhsql
-P--pset, an output setting--profile, a config-file profile
Field separator-F--csv, --format tsv, or any other --format
Listing databases-l--catalog
Describing an object\d, \dt--catalog --path, --catalog-search
Stopping on the first error-v ON_ERROR_STOP=1--on-error stop, the default
One transaction-1write begin and commit in your script
-oa file for query outputa file, or a directory that gets one file per result set
Connection flags-h, -p, -U, built inthe adapter’s, so hsql --help -a postgres lists them
Row limitsnone500 rows by default; --limit -1 removes it
Suppressing chatter-qnothing to suppress: stdout is only ever results
Exit codes1 its own error, 2 connection, 3 script error1 query error, 2 usage/config, 3 connection, 4 timeout
lightbulb icon Warning

-t is tuples only, as in psql, not Harlequin’s theme flag. Connection strings are positional, so hsql -t nord -c "..." parses, nord becomes a connection string, and hsql says so on stderr.

No Backslash Commands

hsql has no meta-commands. What they do, options do:

  • \d, \dt, \l--catalog and --catalog-search, which produce ordinary result sets.
  • \copy--csv and -o, or --format parquet.
  • \timing--stats, which reports elapsed_ms on stderr.
  • \c — a different profile: -P NAME.
  • \set — the profile, or the command line. One invocation, no session variables.

Sessions: Keeping Connections Open

By default, hsql executes what it was passed and exits. Every invocation starts a process, connects, runs its SQL and drops the connection, so nothing it did — a temp table, a SET, an open transaction — reaches the next one. That is the right default for a script or an agent, and it is what every example above assumes.

hsql --serve prod -P prod holds a connection open the way a psql prompt does, and hsql --session prod -c "..." runs against it. There is still no interactive prompt — for that, Harlequin uses the same adapters, config files and profiles: harlequin -P prod — but an invocation served that way answers in milliseconds instead of reconnecting, and finds the temp tables, settings and transactions the one before it left, exactly as a psql session would. See Warm Sessions.