Reference: hsql CLI

View as Markdown

This page is generated from hsql --spec with no adapters loaded, in Harlequin’s repository, and published with the release it describes.

It does not cover any adapter’s connection options. Four commands answer that, and none of them connects to a database:

hsql --help
hsql --help -a postgres
hsql --spec
hsql --info

--help is this list for a person, --help -a NAME adds one adapter’s options to it, and --spec is the whole surface as JSON. --info describes the installation: versions, config files, the active profile, and what each adapter supports.

What the options are for is on the other pages under The hsql CLI.

Generated from hsql 2.13.0, and served verbatim at harlequin.sh/artifacts/hsql-reference.md.

hsql

Execute SQL and exit.

CONN_STR: one or more connection strings, or paths to local db files.

Generated from the bare hsql command, with no adapters loaded. An adapter contributes its own options on top of these: hsql --help -a NAME shows one adapter’s, and hsql --spec reports every installed adapter’s as JSON.

Usage

hsql [OPTIONS] [CONN_STR]...

Arguments

ArgumentTypeAccepts
CONN_STRtextzero or more

Options

Alphabetical by name. Flags are off by default.

OptionTypeValuesDefaultEnv varDescription
-a, --adapterchoiceNAMEduckdbThe installed adapter plug-in to connect with.
--catalogbooleanList the catalog objects one level below --path, and exit without running SQL.
--catalog-searchtextTERMSearch the whole catalog, at every level, for objects whose name contains TERM, and exit without running SQL. Not every adapter can; see --info.
--colorchoiceauto, always, neverneverColor text output. auto follows the terminal and NO_COLOR.
-c, --commandtextExecute SQL. Repeatable.
--configchoiceshow, list-profiles, validate, schema, initReport on the config files hsql found, or write a profile into one, and exit without running SQL. One of: show, list-profiles, validate, schema, init.
--config-pathpathPATHHARLEQUIN_CONFIG_PATHUse this config file instead of the ones hsql discovers.
--csvbooleanShorthand for --format csv.
--display-rowsintegerNRows printed per result set by the text layouts. -1 for all rows. [default: 40 for table, markdown, md; 10 for vertical]
-f, --filetextPATHExecute SQL from a file, or from stdin for -. Repeatable.
--formatchoicetable, markdown, md, vertical, csv, tsv, json, jsonl, ndjson, parquet, orc, feather, arrow, nonetableOutput format. See below for the list.
--helpbooleanShow this message and exit.
--infobooleanVersions, config files, the active profile, and what each installed adapter declares it supports, as JSON. Connects to nothing. -a narrows it to one adapter.
--jsonbooleanShorthand for --format json.
--jsonlbooleanShorthand for --format jsonl.
--limitintegerN500Maximum rows fetched per result set. -1 for no limit.
--markdownbooleanShorthand for --format markdown.
-A, --no-alignbooleanUnaligned output. As in psql.
--no-footerbooleanOmit the row-count footer, keeping other chrome.
--no-headerbooleanOmit the header row, keeping other chrome.
--null-stringtextTEXTRender NULL as TEXT. Defaults to NULL for text formats, empty for csv.
--on-errorchoicestop, continuestopWhat to do when a statement fails.
-o, --outputtextPATHWrite results to PATH instead of stdout. Accepts a file or directory.
--pathtextTEXTWhere in the catalog --catalog looks, and what --catalog-search searches under. Dotted segments, named by the adapter; the top of the catalog by default. A trailing * filters a --catalog listing.
-P, --profiletextLoad a profile from an available config file. Options passed here take precedence over the profile’s. Use the profile named None for Harlequin’s defaults instead of the config file’s default profile.
-r, --read-onlybooleanConnect read-only, and refuse to run at all if the adapter cannot. To check an adapter’s capabilities, use --info.
--resulttextall\|last\|NallWhich result set(s) to emit.
--skillbooleanWrite the Agent Skill for driving hsql, as markdown. -o installs it: ‘hsql --skill -o ~/.claude/skills/hsql/‘.
--specbooleanEvery option here, plus every installed adapter’s, as JSON. -a narrows it to one adapter.
--ssh-allow-reusebooleanWhen the local port is already bound, warn and connect through the listener that has it instead of failing.
--ssh-batch-modebooleanFail rather than prompt for a passphrase, a password or a host key. ssh’s own BatchMode; set it in scripts, CI and cron.
--ssh-forwardtextTEXTA local forward, spelled as ssh -L takes one: LOCAL:HOST:REMOTE. Repeatable. Omit it when your ssh config has the LocalForward.
--ssh-hosttextTEXTOpen an SSH tunnel to this destination first, and connect through it. A Host alias, host, user@host or ssh://user@host:port, passed to ssh verbatim.
--ssh-timeoutnumberSECONDSSeconds to wait for the tunnel’s forwards. [default: 60]
--statsbooleanWrite a one-line JSON summary to stderr.
--timeoutnumberSECONDSCancel the run after SECONDS and exit 4. Refused if the adapter cannot cancel a query; to check, use --info.
-t, --tuples-onlybooleanRows only: no header, no footer. As in psql.
--versionbooleanShow the version and exit.
-x, --verticalbooleanShorthand for --format vertical. As in psql.

-a/--adapter names an installed adapter plug-in. hsql --info reports adapters installed in your environment.

Formats

--format takes one of these names, which affect the layout of data in stdout. Modify output further with options above (e.g., -t, -A, --display-rows). none runs the SQL but generates no output. The suffix is what -o DIRECTORY names a file with.

FormatKindSuffixHolds several result sets
tabletext layout.txtyes
markdowntext layout.mdyes
mdtext layout.mdyes
verticaltext layout.txtyes
csvfile.csvno
tsvfile.tsvno
jsonfile.jsonno
jsonlfile.jsonlyes
ndjsonfile.ndjsonyes
parquetfile.parquetno
orcfile.orcno
featherfile.featherno
arrowfile.arrowno
nonewrites nothingyes

Exit codes

CodeMeaning
0Success.
1The database rejected the SQL.
2A bad flag, a bad profile, or a config file hsql could not read.
3hsql could not connect.
4--timeout ran out, and hsql stopped the run.
130Interrupted.