Debian Codegraph @

docs/generated/hsql-reference.md

raw
1 <!-- Generated by scripts/write_cli_reference.py. Do not edit by hand. -->
2
3 # hsql
4
5 Execute SQL and exit.
6
7 CONN_STR: one or more connection strings, or paths to local db files.
8
9 Generated from the bare `hsql` command, with no adapters loaded. An adapter
10 contributes its own options on top of these: `hsql --help -a NAME` shows one
11 adapter's, and `hsql --spec` reports every installed adapter's as JSON.
12
13 ## Usage
14
15 ```
16 hsql [OPTIONS] [CONN_STR]...
17 ```
18
19 ## Arguments
20
21 | Argument | Type | Accepts |
22 | --- | --- | --- |
23 | `CONN_STR` | text | zero or more |
24
25 ## Options
26
27 Alphabetical by name. Flags are off by default.
28
29 | Option | Type | Values | Default | Env var | Description |
30 | --- | --- | --- | --- | --- | --- |
31 | `-a`, `--adapter` | choice | `NAME` | `duckdb` | | The installed adapter plug-in to connect with. |
32 | `--catalog` | boolean | | | | List the catalog objects one level below --path, and exit without running SQL. |
33 | `--catalog-search` | text | `TERM` | | | Search the whole catalog, at every level, for objects whose name contains TERM, and exit without running SQL. Not every adapter can; see --info. |
34 | `--color` | choice | `auto`, `always`, `never` | `never` | | Color text output. `auto` follows the terminal and NO_COLOR. |
35 | `-c`, `--command` | text | | | | Execute SQL. Repeatable. |
36 | `--config` | choice | `show`, `list-profiles`, `validate`, `schema`, `init` | | | Report 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. |
37 | `--config-path` | path | `PATH` | | `HARLEQUIN_CONFIG_PATH` | Use this config file instead of the ones hsql discovers. |
38 | `--csv` | boolean | | | | Shorthand for --format csv. |
39 | `--display-rows` | integer | `N` | | | Rows printed per result set by the text layouts. -1 for all rows. [default: 40 for table, markdown, md; 10 for vertical] |
40 | `-f`, `--file` | text | `PATH` | | | Execute SQL from a file, or from stdin for `-`. Repeatable. |
41 | `--format` | choice | `table`, `markdown`, `md`, `vertical`, `csv`, `tsv`, `json`, `jsonl`, `ndjson`, `parquet`, `orc`, `feather`, `arrow`, `none` | `table` | | Output format. See below for the list. |
42 | `--help` | boolean | | | | Show this message and exit. |
43 | `--history` | boolean | | | | List the queries harlequin and hsql have run, newest first, and exit without running SQL. --limit says how many; -P, -a or a CONN_STR narrows it to one database. |
44 | `--history-search` | text | `TERM` | | | List the logged queries whose SQL contains TERM, newest first, and exit without running SQL. Scoped like --history. |
45 | `--idle-timeout` | number | `SECONDS` | `1800.0` | | With --serve: stop the session once it has gone SECONDS with no request. 0 for a session that waits as long as it takes. |
46 | `--info` | boolean | | | | Versions, config files, the active profile, and what each installed adapter declares it supports, as JSON. Connects to nothing. -a narrows it to one adapter. |
47 | `--json` | boolean | | | | Shorthand for --format json. |
48 | `--jsonl` | boolean | | | | Shorthand for --format jsonl. |
49 | `--limit` | integer | `N` | `500` | | Maximum rows fetched per result set. -1 for no limit. |
50 | `--markdown` | boolean | | | | Shorthand for --format markdown. |
51 | `--max-lifetime` | number | `SECONDS` | `28800.0` | | With --serve: stop the session SECONDS after it connected, whatever it is doing; a request already running finishes first. 0 for a session that runs until something stops it. |
52 | `-A`, `--no-align` | boolean | | | | Unaligned output. As in psql. |
53 | `--no-footer` | boolean | | | | Omit the row-count footer, keeping other chrome. |
54 | `--no-header` | boolean | | | | Omit the header row, keeping other chrome. |
55 | `--no-write-history` | boolean | | | | Do not record this run's queries in the query history that Harlequin and hsql share. |
56 | `--null-string` | text | `TEXT` | | | Render NULL as TEXT. Defaults to NULL for text formats, empty for csv. |
57 | `--on-error` | choice | `stop`, `continue` | `stop` | | What to do when a statement fails. |
58 | `-o`, `--output` | text | `PATH` | | | Write results to PATH instead of stdout. Accepts a file or directory. |
59 | `--path` | text | `TEXT` | | | Where 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. |
60 | `-P`, `--profile` | text | | | | Load 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. |
61 | `--queue-timeout` | number | `SECONDS` | | | With --serve: a request waits at most SECONDS for the one before it, then exits 4 without reaching the database. [default: no limit] |
62 | `-r`, `--read-only` | boolean | | | | Connect read-only, and refuse to run at all if the adapter cannot. To check an adapter's capabilities, use --info. |
63 | `--result` | text | `all\|last\|N` | `all` | | Which result set(s) to emit. |
64 | `--serve` | text | `NAME` | | | Connect, then hold the connection open as the session named NAME and answer `--session NAME` invocations from it until stopped. Takes connection and session-lifetime options; no per-request ones. Not on native Windows. |
65 | `--session` | text | `NAME` | | | Send this invocation to the running session named NAME, started with --serve. HSQL_SESSION=NAME does the same for every invocation, and runs without the session, with a warning, when none is up. |
66 | `--session-reset` | boolean | | | | Ask the session to close its connection and open a fresh one, and exit without running SQL. Temp tables, settings and an open transaction are gone. Needs --session. |
67 | `--session-status` | boolean | | | | Poll the server for its status as JSON, and exit. Reports while a query is running. Needs --session. |
68 | `--skill` | boolean | | | | Write the Agent Skill for driving hsql, as markdown. -o installs it: 'hsql --skill -o ~/.claude/skills/hsql/'. |
69 | `--spec` | boolean | | | | Every option here, plus every installed adapter's, as JSON. -a narrows it to one adapter. |
70 | `--ssh-allow-reuse` | boolean | | | | When the local port is already bound, warn and connect through the listener that has it instead of failing. |
71 | `--ssh-batch-mode` | boolean | | | | Fail rather than prompt for a passphrase, a password or a host key. ssh's own BatchMode; set it in scripts, CI and cron. |
72 | `--ssh-forward` | text | `TEXT` | | | A local forward, spelled as ssh -L takes one: LOCAL:HOST:REMOTE. Repeatable. Omit it when your ssh config has the LocalForward. |
73 | `--ssh-host` | text | `TEXT` | | | Open 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. |
74 | `--ssh-timeout` | number | `SECONDS` | | | Seconds to wait for the tunnel's forwards. [default: 60] |
75 | `--stats` | boolean | | | | Write a one-line JSON summary to stderr. |
76 | `--timeout` | number | `SECONDS` | | | Cancel the run after SECONDS and exit 4. Refused if the adapter cannot cancel a query; to check, use --info. |
77 | `-t`, `--tuples-only` | boolean | | | | Rows only: no header, no footer. As in psql. |
78 | `--version` | boolean | | | | Show the version and exit. |
79 | `-x`, `--vertical` | boolean | | | | Shorthand for --format vertical. As in psql. |
80
81 `-a`/`--adapter` names an installed adapter plug-in. `hsql --info` reports
82 adapters installed in your environment.
83
84 ## Formats
85
86 `--format` takes one of these names, which affect the layout of data in stdout.
87 Modify output further with options above (e.g., `-t`, `-A`, `--display-rows`).
88 `none` runs the SQL but generates no output. The suffix is what `-o DIRECTORY`
89 names a file with.
90
91 | Format | Kind | Suffix | Holds several result sets |
92 | --- | --- | --- | --- |
93 | `table` | text layout | `.txt` | yes |
94 | `markdown` | text layout | `.md` | yes |
95 | `md` | text layout | `.md` | yes |
96 | `vertical` | text layout | `.txt` | yes |
97 | `csv` | file | `.csv` | no |
98 | `tsv` | file | `.tsv` | no |
99 | `json` | file | `.json` | no |
100 | `jsonl` | file | `.jsonl` | yes |
101 | `ndjson` | file | `.ndjson` | yes |
102 | `parquet` | file | `.parquet` | no |
103 | `orc` | file | `.orc` | no |
104 | `feather` | file | `.feather` | no |
105 | `arrow` | file | `.arrow` | no |
106 | `none` | writes nothing | | yes |
107
108 ## Exit codes
109
110 | Code | Meaning |
111 | --- | --- |
112 | `0` | Success. |
113 | `1` | The database rejected the SQL. |
114 | `2` | A bad flag, a bad profile, or a config file hsql could not read. |
115 | `3` | hsql could not connect. |
116 | `4` | `--timeout` ran out, and hsql stopped the run. |
117 | `70` | hsql hit a bug in itself and wrote a crash report. |
118 | `130` | Interrupted. |