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.
Uninstall
Section titled “Uninstall”Run DBCode: Uninstall CLI from the command palette, or dbcode uninstall from a terminal. Either removes the link that install created (on Windows, the folder and its PATH entry too). Uninstalling the DBCode extension removes the link as well.
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 |
Dev Containers, Remote-SSH and WSL
Section titled “Dev Containers, Remote-SSH and WSL”In a VS Code window connected to a Dev Container, an SSH host or WSL, dbcode query runs in that window’s terminals, and in scripts, notebooks and debug sessions started there. DBCode in that window runs the SQL on the connections it shows. Run DBCode: Install CLI in that window to put dbcode on its path.
- Output formats and exit codes are the same as in any other terminal.
--database,--schema,--limitand--no-limitwork as usual.--timeoutcounts the whole wait, including a confirmation prompt in VS Code. Ctrl+C cancels the running query.- The query runs on the connection the editor already has open for that database, so a
USEorSETin a script also applies in the editor, and the connection stays open in the explorer. - A statement your environment role marks “ask” shows its confirmation in VS Code.
--yesapproves it, as in any other terminal. --app,--profileand--workspaceread the settings files on the container or remote host instead.
If the CLI reports that DBCode is not running in the window, open the DBCode view or reload the window. dbcode connections, dbcode open and dbcode introspect work there too.
Privacy
Section titled “Privacy”The CLI follows the editor’s telemetry.telemetryLevel and dbcode.disableOnlineServices settings. It reads the editor’s secret store only for the password of the connection you use and, for dbcode mcp, the stored licence. It never writes to it and never prints a secret.
DBCODE_DEBUG=1 writes diagnostics to stderr, including raw driver errors. Leave it off unless you are diagnosing a problem.