The native terminal client for NodeDB. Syntax highlighting, tab completion, multiple output formats, and a full TUI — built in Rust.
ndb connects via NodeDB's binary MessagePack protocol for lower latency and richer type support than pgwire. It works anywhere NodeDB runs.
cargo install nodedb-cliPre-built binaries for Linux (x64, arm64), macOS (x64, arm64), and Windows (x64) are available on the releases page.
# Connect to localhost:6433 (default)
ndb
# Specify host and port
ndb -h db.example.com -p 6433
# With authentication
ndb -u admin -w # prompt for password
# Execute a query and exit
ndb -e "SELECT * FROM users LIMIT 10"
# Execute from file
ndb -f queries.sql
# Pipe input
echo "SELECT 1" | ndb| Flag | Long | Default | Description |
|---|---|---|---|
-h |
--host |
127.0.0.1 |
Server host |
-p |
--port |
6433 |
Server port (native protocol) |
-u |
--user |
admin |
Username |
-w |
--password |
Password (prompts if flag given without value) | |
-e |
--execute |
Execute SQL and exit | |
-f |
--file |
Execute SQL from file and exit | |
-o |
--output |
Write output to file | |
--tls |
off | Enable TLS encryption | |
--tls-ca-cert |
Path to CA certificate (PEM) | ||
--format |
table |
Output format: table, json, csv |
| Variable | Description | Precedence |
|---|---|---|
NODEDB_HOST |
Server host | env > config file > default |
NODEDB_PORT |
Server port | env > config file > default |
NODEDB_USER |
Username | env > config file > default |
NODEDB_PASSWORD |
Password | env > config file > default |
CLI flags always take highest precedence.
- Syntax highlighting -- Keywords, strings, numbers, and comments are color-coded
- Tab completion -- SQL keywords, collection names, and column names (context-aware after
FROM) - History search --
Ctrl+Rfor reverse search through command history - Persistent history -- Commands saved across sessions
- Multi-line editing -- Write complex queries naturally
- External editor --
\eopens your$VISUAL/$EDITORfor editing the current query
| Command | Description |
|---|---|
\d |
List collections |
\d <name> |
Describe a collection |
\x |
Toggle expanded (vertical) display |
\e |
Open external editor |
\g <file> |
Write last result to file |
\watch N |
Re-run query every N seconds |
\conninfo |
Show connection details |
\format <fmt> |
Set output format (table, json, csv) |
# Table (default)
ndb -e "SELECT * FROM users"
# JSON (NDJSON)
ndb --format json -e "SELECT * FROM users"
# CSV
ndb --format csv -e "SELECT * FROM users" -o users.csv
# Toggle expanded display interactively
\x
SELECT * FROM users;~/.config/nodedb/config.toml:
[connection]
host = "localhost"
port = 6433
[display]
format = "table" # table, json, csv
expanded = falsegit clone https://github.com/NodeDB-Lab/nodedb-cli.git
cd nodedb-cli
cargo build --releaseThe binary is at target/release/ndb.
For local development against the NodeDB workspace, create .cargo/config.toml:
[patch.crates-io]
nodedb-client = { path = "../nodedb/nodedb-client" }
nodedb-types = { path = "../nodedb/nodedb-types" }Apache-2.0. See LICENSE for details.