Skip to content

Command line

Install the DataRunner command line, authenticate, and turn a query into a build step.

Install

A single self-contained binary. The machine needs nothing installed first, neither a runtime nor a package manager. That is what makes it usable in a lean CI image.

Linux and macOS
curl -fsSL https://api.datarunner.app/downloads/cli/install.sh | bash
Windows
irm https://api.datarunner.app/downloads/cli/install.ps1 | iex

Neither asks for root or administrator: it installs into a user directory and adjusts that user PATH. The installer verifies the published SHA256 before installing and refuses on a mismatch.

Pin the version in CI. A job that resolves “latest” on every run changes behaviour without anybody making a commit.

curl -fsSL https://api.datarunner.app/downloads/cli/install.sh | bash -s -- --version 0.1.1

The first five minutes

After installing, this is a whole session end to end. The step that usually goes missing is the second one: a query has an id, and listing is the only place it comes from.

  1. Log in, once per machine. The key comes from Settings → API keys in the console, and is only shown at the moment you create it. The command asks for it without echoing, so it never goes through the command line or into shell history.
  2. List what exists in the workspace. This is where the id the other commands want comes from.
  3. Run a query and look at the result.
  4. Turn that query into a check the build understands.
1 · log in
datarunner auth login

  → chave: ••••••••••••••••••••••••

  ✔ servidor respondeu       api.datarunner.app • 84 ms
  ✔ chave aceita             you@acme.com • admin • Acme
  ✔ perfil 'default' salvo   cifrado para este usuário do Windows (DPAPI)
2 · see what exists
datarunner query list

id                                    nome             conexao     atualizada
────────────────────────────────────  ───────────────  ──────────  ──────────────
3f2a91c4-8e17-4b2a-9f03-1d5c7e8a2b60  Monthly revenue  Postgres    2026-09-01 14:22
a7c04e12-3b95-4d81-b6ef-92a10c4d7f38  Orphan orders    Postgres    2026-08-28 09:10
3 · run it
datarunner query run 3f2a91c4-8e17-4b2a-9f03-1d5c7e8a2b60

month       total
──────────  ─────────
2026-07     184320.50
2026-08     201455.00

2 linha(s) em 340ms.
4 · make it a build check
datarunner query assert a7c04e12-3b95-4d81-b6ef-92a10c4d7f38 --expect-empty

ok — 0 linha(s) em 120ms.

That last command exits 0 when no row came back and 1 when one did. That, and only that, is what stops the build when data integrity broke.

Credential

The key comes from Settings → API keys. Its scopes narrow what the tool reaches on top of the role of whoever created it: a restricted key stays restricted even when it belongs to an admin, and a key never grants platform-wide powers.

On your machine: asks for the key without echoing
datarunner auth login
datarunner auth login --url https://datarunner.yourcompany.com   # self-hosted
In CI: nothing is written to disk
export DATARUNNER_URL=https://api.datarunner.app
export DATARUNNER_KEY=dr_...

To run queries in CI, tick the run:queries scope. It already includes reading and cannot change anything. Listing queries and executing SQL against a production database are different powers, so read:queries alone does not run.

API keys are available from Team up, so the command line is too; Solo and Pro do not have it.

A query as a build step

A query that lists orphaned rows is something anybody can write today and cannot enforce anywhere. With the command below it becomes a build step: if a migration broke referential integrity, the build fails instead of production finding out later.

datarunner query assert 3f2a... --expect-empty
CheckFails when
--expect-emptyany row came back
--expect-rows <n>the count is not exactly that
--min-rows <n>fewer than that came back
--max-rows <n>more than that came back

If the result hits the plan row cap, the check fails rather than passes. A truncated count is not a count, and an --expect-empty that passes because the cap hid the rows is worse than no check at all, because somebody is relying on it.

Every command

CommandWhat it doesKey scope
auth login | list | use | logoutstores and switches credentials—
whoamichecks the current credential—
query listlists queries, with the idread:queries
query run <id>runs and printsrun:queries
query assert <id>runs and checks; exits 1 on failurerun:queries
monitor list | statusmonitor stateread:monitors
connection listlists connectionsread:connections

Every command has its own help: datarunner help query, datarunner help monitor, and so on. datarunner help ci prints a ready CI file.

run:queries already includes reading, so a CI key that only checks data needs nothing else. Listing queries and executing SQL against a production database are different powers, which is why read:queries alone does not run anything.

Working with more than one environment

The first thing anybody does with this is point it at staging and then at production. Profiles exist so that switch is not another login.

datarunner auth login --url https://api.acme.dev --profile dev
datarunner auth login --url https://api.acme.com --profile prod

datarunner auth use prod
datarunner query list --profile dev    # without switching the current one

The file lives at ~/.datarunner/config.json. On Windows the key is sealed with DPAPI for your user: the file copied to another machine, another account or a backup does not open. On Linux and macOS, mode 600 in a 700 directory. Logout removes the profile from your machine; the key stays valid on the server until somebody revokes it in the console.

Interactive mode

Type just datarunner in a terminal. The opening screen connects to the server and shows who you are and which workspace you are in; then a prompt takes the same commands without the prefix. Scripts and CI see no change: with no terminal, the bare binary still prints the help and exits 2.

datarunner:prod › query run Monthly rev⇥
datarunner:prod › query run 3f2a91c4-8e17-4b2a-9f03-1d5c7e8a2b60
→ Monthly revenue (3f2a91c4)
  • Tab completes commands, options and ids by name. The list comes from the API, with your key's permissions.
  • Wherever a command takes an id, a name or the start of the id works too, in and out of interactive mode. If it matches more than one, the CLI refuses and lists them instead of picking.
  • Ctrl+C stops the running command, not the shell. History lives in memory only and never keeps a line carrying a key.

AI agents (MCP)

The CLI is also an MCP (Model Context Protocol) server. Claude Desktop, Claude Code, Cursor and Windsurf get to see the workspace: connections, schemas, saved queries, read-only SQL, monitors and alerts. The agent can do at most what the key can, because permissions are checked on the server, exactly as for the console.

Connect in one command
datarunner auth login
datarunner mcp install claude-desktop    # or: cursor, windsurf, claude-code

datarunner mcp tools                     # what the agent can do with this key
  • No key goes into the AI client's config: it points at the profile, which stays sealed. The profile is pinned by name, so a later auth use prod does not repoint the agent at production.
  • Read-only by default. Acknowledging alerts and testing connections are not even shown to the model without --allow-writes.
  • Every id is validated before it becomes a URL, queries are rate-limited per minute, and the instructions tell the model that database content is data, never instructions.

Free-form SQL takes the same path as the console editor: the server refuses destructive statements and applies column-masking policies before the result reaches the model.

Output and exit codes

The default format is a table. Pass --json or --csv when a program will read the output. Only then does progress go to standard error, so it cannot dirty what you are capturing. Nothing is guessed: PowerShell reports output as redirected even at an ordinary prompt, so trying to detect it printed JSON at people who just wanted to look.

datarunner query run 3f2a... | jq '.rows[0]'
datarunner query run 3f2a... --format csv > revenue.csv
CodeMeans
0ok
1a check you asked for failed (the tool worked)
2wrong usage
3credential missing or refused
4the server refused, or could not be reached

The split between 1 and 4 is the point: a build has to tell “the data is wrong” from “the tool is broken” without parsing prose.

Other commands

  • datarunner monitor status --fail-on-down: hold a deploy while something is already down.
  • datarunner query list, connection list, whoami.