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 | `--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. |
44 | `--json` | boolean | | | | Shorthand for --format json. |
45 | `--jsonl` | boolean | | | | Shorthand for --format jsonl. |
46 | `--limit` | integer | `N` | `500` | | Maximum rows fetched per result set. -1 for no limit. |
47 | `--markdown` | boolean | | | | Shorthand for --format markdown. |
48 | `-A`, `--no-align` | boolean | | | | Unaligned output. As in psql. |
49 | `--no-footer` | boolean | | | | Omit the row-count footer, keeping other chrome. |
50 | `--no-header` | boolean | | | | Omit the header row, keeping other chrome. |
51 | `--null-string` | text | `TEXT` | | | Render NULL as TEXT. Defaults to NULL for text formats, empty for csv. |
52 | `--on-error` | choice | `stop`, `continue` | `stop` | | What to do when a statement fails. |
53 | `-o`, `--output` | text | `PATH` | | | Write results to PATH instead of stdout. Accepts a file or directory. |
54 | `--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. |
55 | `-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. |
56 | `-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. |
57 | `--result` | text | `all\|last\|N` | `all` | | Which result set(s) to emit. |
58 | `--skill` | boolean | | | | Write the Agent Skill for driving hsql, as markdown. -o installs it: 'hsql --skill -o ~/.claude/skills/hsql/'. |
59 | `--spec` | boolean | | | | Every option here, plus every installed adapter's, as JSON. -a narrows it to one adapter. |
60 | `--ssh-allow-reuse` | boolean | | | | When the local port is already bound, warn and connect through the listener that has it instead of failing. |
61 | `--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. |
62 | `--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. |
63 | `--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. |
64 | `--ssh-timeout` | number | `SECONDS` | | | Seconds to wait for the tunnel's forwards. [default: 60] |
65 | `--stats` | boolean | | | | Write a one-line JSON summary to stderr. |
66 | `--timeout` | number | `SECONDS` | | | Cancel the run after SECONDS and exit 4. Refused if the adapter cannot cancel a query; to check, use --info. |
67 | `-t`, `--tuples-only` | boolean | | | | Rows only: no header, no footer. As in psql. |
68 | `--version` | boolean | | | | Show the version and exit. |
69 | `-x`, `--vertical` | boolean | | | | Shorthand for --format vertical. As in psql. |
70
71 `-a`/`--adapter` names an installed adapter plug-in. `hsql --info` reports
72 adapters installed in your environment.
73
74 ## Formats
75
76 `--format` takes one of these names, which affect the layout of data in stdout.
77 Modify output further with options above (e.g., `-t`, `-A`, `--display-rows`).
78 `none` runs the SQL but generates no output. The suffix is what `-o DIRECTORY`
79 names a file with.
80
81 | Format | Kind | Suffix | Holds several result sets |
82 | --- | --- | --- | --- |
83 | `table` | text layout | `.txt` | yes |
84 | `markdown` | text layout | `.md` | yes |
85 | `md` | text layout | `.md` | yes |
86 | `vertical` | text layout | `.txt` | yes |
87 | `csv` | file | `.csv` | no |
88 | `tsv` | file | `.tsv` | no |
89 | `json` | file | `.json` | no |
90 | `jsonl` | file | `.jsonl` | yes |
91 | `ndjson` | file | `.ndjson` | yes |
92 | `parquet` | file | `.parquet` | no |
93 | `orc` | file | `.orc` | no |
94 | `feather` | file | `.feather` | no |
95 | `arrow` | file | `.arrow` | no |
96 | `none` | writes nothing | | yes |
97
98 ## Exit codes
99
100 | Code | Meaning |
101 | --- | --- |
102 | `0` | Success. |
103 | `1` | The database rejected the SQL. |
104 | `2` | A bad flag, a bad profile, or a config file hsql could not read. |
105 | `3` | hsql could not connect. |
106 | `4` | `--timeout` ran out, and hsql stopped the run. |
107 | `130` | Interrupted. |