Skip to content
Keepware Subscribe

The qdb command line: query your databases from the terminal

qdb is QuerentDB's command line: list connections, describe tables and run queries into CSV, JSON or jq from any terminal, with your permissions and approvals.

Part 11 of 13· Nov 11, 2026·4 min read

qdb is the command line that comes with QuerentDB, a desktop database client by Keepware. It lists your environments and connections, describes tables and collections, runs read-only queries and prints the results as a table, CSV, JSON or JSON Lines, or pipes them through jq. Writes go through qdb exec, which waits for you to approve them in QuerentDB. qdb never connects to a database itself: every command goes through the running QuerentDB app, so passwords and SSH tunnels stay there, and the same permissions and AI policies apply.

How do I set up qdb?

QuerentDB offers it the first time you open the app (Set up the qdb command?), and any time later in Settings → MCP & CLI → The qdb command:

  1. Add to PATH puts qdb where your terminal finds it. On Windows it’s added to your own user PATH, so no admin rights are needed; open a new terminal afterwards. On Ubuntu the .deb package already installed it as /usr/bin/qdb.
  2. Terminal sign-in → Set up creates a token for the command line, named qdb CLI, and saves it in %APPDATA%\QuerentDB\qdb.json on Windows or ~/.config/querentdb/qdb.json on Ubuntu. It also turns on the local MCP server if it was off.

Settings → MCP & CLI → The qdb command: Add to PATH and Terminal sign-in

Check it:

$ qdb status
QuerentDB  http://127.0.0.1:7466/mcp
token      qdb_pat_U5Kx… (config)
workspace  Personal
connections 5 in 2 environments

qdb talks to QuerentDB’s local MCP server at 127.0.0.1:7466. If QuerentDB isn’t open, qdb opens it and waits for it.

How do I list my environments and connections?

$ qdb envs
ENVIRONMENT  ACCESS  PROTECTED  AI POLICY
───────────  ──────  ─────────  ─────────
dev          write              full
prod         write   protected  full
$ qdb ls
CONNECTION         ENGINE    DATABASE        ID
─────────────────  ────────  ──────────────  ────────────────────────────────────
dev/acme-es        elastic                   33925607-5709-4282-b9bd-0f8d81e486f3
dev/acme-mysql     mysql     acme_store      4eb22544-97ad-4074-a4ea-bf8d2433b92d
dev/acme-postgres  postgres  acme_analytics  52fd1eee-519e-420c-be8d-c9fd1bdb4579
dev/acme-mongo     mongo     acme_catalog    860d9ea0-fb0d-4ee7-af06-65889f4c9291
prod/acme-mysql    mysql     acme_store      8d5474e7-dabc-4473-a3d2-84c4077ec252

Refer to a connection as environment/name, such as dev/acme-mysql, or by its ID. A name on its own works when no other environment has a connection with that name.

How do I see a database’s tables or a table’s columns?

qdb describe lists the tables, collections or indices, and with an object name, its structure:

$ qdb describe dev/acme-mysql -d acme_store
NAME         KIND   ROWS
───────────  ─────  ────
customers    table  60
order_items  table  822
orders       table  400
products     table  12
$ qdb describe dev/acme-mysql orders -d acme_store
COLUMN       TYPE                                         NULL  KEY
───────────  ───────────────────────────────────────────  ────  ───
id           int                                                PRI
customer_id  int                                                MUL
status       enum('pending','paid','shipped','refunded')        MUL
total        decimal(10,2)
created_at   datetime                                           MUL

How do I run a query?

$ qdb query dev/acme-mysql -d acme_store "SELECT status, COUNT(*) AS orders, SUM(total) AS revenue FROM orders GROUP BY status"
status    orders  revenue
────────  ──────  ────────
pending   44      6005.50
paid      181     26562.50
shipped   157     20708.00
refunded  18      2654.00
4 rows

In a terminal you get a table. When the output is piped or written to a file, it’s CSV; choose with --format table, csv, json or jsonl:

$ qdb query dev/acme-mysql -d acme_store "SELECT id, name, email, city FROM customers ORDER BY id" --format csv --limit 3
id,name,email,city
1,Harper Walker,[email protected],San Diego
2,Owen Davis,[email protected],Nashville
3,Noah Young,[email protected],San Diego
3 rows

-o FILE writes the results to a file; the row count goes to the terminal:

$ qdb query dev/acme-mysql -d acme_store "SELECT * FROM orders" -o orders.csv
400 rows → orders.csv

Read a statement from a file with -f query.sql, or from standard input with - (or by just piping it in):

$ echo "SELECT COUNT(*) AS customers FROM customers" | qdb query dev/acme-mysql -d acme_store
customers
60
1 row

qdb query returns up to 1,000 rows unless you pass --limit N, and never more than the workspace’s Max rows per query (10,000 by default). When the result is cut off, the count line says so.

How do I process results with jq?

--jq EXPR hands the rows to jq as a JSON array of objects; strings come out as plain text, ready for the next command:

$ qdb query dev/acme-postgres -d acme_analytics "SELECT channel, SUM(budget) AS budget FROM marketing.campaigns GROUP BY channel ORDER BY 2 DESC" --jq '.[] | "\(.channel)\t\(.budget)"'
social	6300.00
search	3400.00
email	2150.00
partner	1800.00
4 rows

jq must be installed on your computer.

Does qdb work with MongoDB and Elasticsearch?

Yes. For MongoDB, use the same statements as in QuerentDB’s MongoDB editor; documents print one per line:

$ qdb query dev/acme-mongo -d acme_catalog 'db.reviews.find({ rating: { $lte: 2 } }, { product: 1, rating: 1, title: 1, _id: 0 })' --limit 3
{"product":"Wool Socks","rating":1,"title":"Arrived damaged"}
{"product":"Plant Pot","rating":2,"title":"Arrived damaged"}
{"product":"Wall Clock","rating":1,"title":"Not for me"}
3 documents

For Elasticsearch and OpenSearch, write the request as METHOD /path with its JSON body, on one line or on the next:

$ qdb query dev/acme-es 'GET /products/_search {"query": {"match": {"description": "coffee"}}}' --format csv
_index,_id,_score,sku,name,description,price,tags,in_stock,rating
products,MUG-01,1.9203849,MUG-01,Trail Mug,Enamel camp mug that keeps coffee warm on the trail.,18,"[""kitchen"",""outdoor""]",true,3.7
1 document

How do writes work with qdb?

qdb query only runs reads:

$ qdb query dev/acme-mysql -d acme_store "UPDATE products SET stock = 40 WHERE sku = 'MUG-01'"
qdb: qdb query only runs reads: use qdb exec for writes (you approve them in QuerentDB)

Use qdb exec. It waits while QuerentDB asks you to approve the statement, with the number of rows it’s expected to change:

QuerentDB asks before a write from qdb: the statement, the rows it affects, Deny or Allow once

$ qdb exec dev/acme-mysql -d acme_store "UPDATE products SET stock = 40 WHERE sku = 'MUG-01'"
Waiting for approval in QuerentDB…
1 row affected

If you don’t answer within a minute, the write is denied. In a protected environment you also type the environment’s name before Allow once is available. Your access still applies: in an environment where you’re read-only, qdb exec is refused.

Which commands are there?

CommandWhat it does
qdb envsEnvironments, with your access, protection and AI policy
qdb ls [ENVIRONMENT]Connections, all or one environment’s
qdb describe CONN [OBJECT] [-d DB]Tables, collections or indices, or one object’s structure
qdb query CONN [-d DB] [STATEMENT | -f FILE | -]A read-only statement: --format, --limit, -o, --jq
qdb explain CONN [-d DB] STATEMENTThe execution plan
qdb exec CONN [-d DB] STATEMENTA write, after you approve it in QuerentDB
qdb audit [--member …] [--env …] [--source …]A team’s audit log
qdb login [--token TOKEN] [--url URL]Save a token you created in Settings → MCP & CLI
qdb logout · qdb status · qdb --versionForget the saved token, show the connection, the version

qdb help prints all of it. --json gives raw JSON for ls and describe. On an error, qdb prints qdb: <message> and exits with status 1.

FAQ

Can I use my own token instead of Terminal sign-in?

Yes. Create a token in Settings → MCP & CLI → Personal tokens, then run qdb login and paste it, or set the QDB_TOKEN environment variable for one session. qdb logout deletes the saved file; revoke the token in QuerentDB to stop it working everywhere.

Does qdb work without QuerentDB running?

No. qdb reaches your databases through the app: that’s how passwords, SSH tunnels, permissions and approvals stay in one place. If QuerentDB isn’t open, qdb starts it.

Are qdb commands in the audit log?

In a team workspace with the audit log on, yes: they’re recorded with the source MCP, under your name.

Can the AI policy block qdb?

Yes. In an environment whose AI policy is Off, qdb doesn’t see its connections; with Schema only, it can describe structure but not read data.