Skip to content

NodeDB-Lab/nodedb-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ndb

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.

Install

cargo install nodedb-cli

Pre-built binaries for Linux (x64, arm64), macOS (x64, arm64), and Windows (x64) are available on the releases page.

Quick Start

# 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

CLI Flags

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

Environment Variables

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.

Interactive Features

  • 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+R for reverse search through command history
  • Persistent history -- Commands saved across sessions
  • Multi-line editing -- Write complex queries naturally
  • External editor -- \e opens your $VISUAL / $EDITOR for editing the current query

Meta-Commands

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)

Output Formats

# 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;

Configuration

~/.config/nodedb/config.toml:

[connection]
host = "localhost"
port = 6433

[display]
format = "table"      # table, json, csv
expanded = false

Building from Source

git clone https://github.com/NodeDB-Lab/nodedb-cli.git
cd nodedb-cli
cargo build --release

The 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" }

License

Apache-2.0. See LICENSE for details.

About

NodeDB terminal UI and CLI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages