Installing and running
- CLI
querybara is the command-line tool that runs the same engine as the desktop app, without a window.
Use it in scripts and CI jobs to test connections, run SQL, compare and sync databases, move data,
and back up and restore. It reads and writes the same saved connections as the desktop app.
Requirements
Section titled “Requirements”- Node.js 22.13 or later. Parquet files with ZSTD compression need Node.js 22.15 or later.
- pnpm 10. Run
corepack enablein the checkout to pick up the pinned version.
Build the CLI
Section titled “Build the CLI”The CLI is built from the Querybara source. From the root of the checkout:
pnpm installpnpm --filter @querybara/cli buildnode apps/cli/dist/querybara.mjs --helpThe build writes one file, apps/cli/dist/querybara.mjs. The database drivers (pg, mysql2,
mongodb, ioredis) and the SSH and SOCKS libraries are not bundled into it; pnpm install puts
them in the workspace. Run the file from the checkout you built it in.
In this reference, querybara stands for node apps/cli/dist/querybara.mjs. To type it the short
way, define a shell alias from the checkout root:
alias querybara="node $PWD/apps/cli/dist/querybara.mjs"querybara --versionSaved connections
Section titled “Saved connections”The CLI shares the desktop app’s local store, so every connection you save in the app is a target you can name on the command line:
querybara test shop-prodquerybara query shop-prod -e "select count(*) from shop.orders"By default the CLI opens the store where the desktop app keeps it, the file querybara.db in the
app’s data folder:
| System | Default store |
|---|---|
| Linux | ~/.config/Querybara/querybara.db (or $XDG_CONFIG_HOME/Querybara/querybara.db) |
| macOS | ~/Library/Application Support/Querybara/querybara.db |
| Windows | %APPDATA%\Querybara\querybara.db |
To use another store, pass --store <path> or set QUERYBARA_STORE. The CLI picks the first of:
--storeQUERYBARA_STOREQUERYBARA_USER_DATA_DIR(the desktop app’s own data folder override), withquerybara.dbinside- the default above
When --store or QUERYBARA_STORE names an existing folder, the CLI uses querybara.db inside it.
querybara --store ./ci-store.db profiles listQUERYBARA_STORE=/srv/querybara/store.db querybara test shop-stagingCommands that only read, such as profiles list or resolving a profile name, do not create a
store that does not exist yet. A CI job that only uses connection URIs leaves no store file
behind.
Passwords on the command line
Section titled “Passwords on the command line”The desktop app seals saved passwords with the OS keychain, which the CLI cannot open. When the CLI needs a password for a saved profile, it takes the first of:
- a password the CLI itself saved, sealed with
QUERYBARA_PASSPHRASE QUERYBARA_PASSWORD_<NAME>for that profile, thenQUERYBARA_PASSWORD- a hidden prompt, when a terminal is attached
A password in a connection URI is used for that run only and never stored. See Global options and environment for every variable.
Related
Section titled “Related”Documents Querybara 0.1.1 · built frombc9f5aa