CLI
Command Line
The dbcode command runs queries against the connections you already saved in DBCode. It reads the same settings files your editor does, so there is nothing to configure twice.
Install
Section titled “Install”- Run DBCode: Install CLI from the command palette. It links
dbcodeinto a folder on your PATH (/usr/local/bin,~/.local/binor~/binon macOS and Linux;%LOCALAPPDATA%\Programs\dbcodeon Windows, which is added to your user PATH). - Open a new terminal and run
dbcode --version.
The CLI runs under the Node.js on your PATH and needs Node 22.14 or newer. Extension updates keep the link pointing at the current version.
First query
Section titled “First query”dbcode connectionsdbcode query -c "My Postgres" "select now()"-c takes a connection name, or its id when two connections share a name. SQL comes from the argument, from --file, or from stdin:
cat report.sql | dbcode query -c warehouse --format csv > report.csvSQL that starts with a -- comment must follow a literal -- so the argument parser does not read it as a flag:
dbcode query -c prod -- "-- daily countselect count(*) from orders"Output formats
Section titled “Output formats”| Format | When |
|---|---|
table | Default on a terminal |
json | Default when piped. One array of row objects per result set |
jsonl | One object per line |
csv, tsv | Byte-identical to the grid’s Export |
markdown | For pasting into docs and chat |
Only data goes to stdout. Status lines (INSERT 2), the row-limit notice and errors go to stderr.
Options
Section titled “Options”| Flag | Meaning |
|---|---|
--database, --schema | Override the connection’s defaults for this run |
--limit N, --no-limit | Row cap. Defaults to the dbcode.queryRowLimit setting |
--timeout S | Request timeout in seconds |
-y, --yes | Approve statements your environment role marks as “ask” |
--app, --profile, --workspace | Which editor, profile and workspace folder supply the settings |
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
| 0 | Success, including truncated results |
| 1 | The database returned an error |
| 2 | Usage error, unknown connection, unsupported connection |
| 3 | Could not connect or authenticate |
| 4 | Refused by your environment role, or you answered no |
| 130 | Interrupted |