Skip to content

Repository files navigation

🌳 sqltree

npm versionLicense: MITNode.jsTestsCoverageBuy Me A CoffeeTutorial

A beautiful, interactive terminal database client for PostgreSQL, MySQL, and many compatible databases. Navigate your databases with a tree browser, run SQL in a full-screen REPL — all from your terminal.

 ╔══════════════════════════════════════╗
║ 🌳 sqltree v1.4 ║
║ PostgreSQL · MySQL · CLI Client ║
╚══════════════════════════════════════╝

Supported Databases

PostgreSQL-compatible: PostgreSQL, CockroachDB, Redshift, YugabyteDB, TimescaleDB, Supabase, Neon, AlloyDB, Aurora PostgreSQL

MySQL-compatible: MySQL, MariaDB, TiDB, SingleStore, PlanetScale, Vitess, Aurora MySQL, Percona

Features

  • Two-column TUI — tree browser on the left, detail panel on the right
  • Interactive tree navigation — browse databases, schemas, tables, and roles with arrow keys
  • Full-screen SQL REPL — press Tab or s to enter SQL mode with auto-completion
  • 20+ databases, one tool — PostgreSQL, MySQL, and many compatible databases with a unified interface
  • Database switching — select a different database in the tree to reconnect automatically
  • Paginated browsing — press Enter on a table to browse data page by page
  • Export — save query results to CSV or JSON
  • Saved connections — store and reuse connection profiles
  • Tab completion — SQL keywords and table names in REPL mode
  • ASCII mode — works in terminals without Unicode/emoji support
  • Extensible adapters — register custom database adapters via registerAdapter()

Quick Start

The easiest way to use sqltree is with npx — no install needed:

# Interactive mode — guided connection setup
npx sqltree
# Connect via URI
npx sqltree --uri postgresql://user:pass@localhost:5432/mydb
npx sqltree --uri mysql://root:secret@127.0.0.1:3306/app
# Connect with individual params
npx sqltree -t postgres -H localhost -p 5432 -U postgres -d mydb
npx sqltree -t mysql -H 127.0.0.1 -U root -d test# Use DATABASE_URL environment variable
DATABASE_URL=postgresql://user:pass@localhost/mydb npx sqltree

CLI Options

FlagDescription
--uri <url>Connection URI
-t, --type <type>Database type (postgres, mysql, cockroachdb, etc.)
-H, --host <host>Database host
-p, --port <port>Database port
-U, --user <user>Database user
-P, --password <pass>Database password
-d, --database <name>Database name
--page-size <n>Rows per page when browsing tables (default: 50)
--timeout <ms>Connection timeout in milliseconds (default: 10000)
--sslEnable SSL for the connection
--ssl-reject-unauthorized <bool>Verify SSL certificates (default: true)
--asciiUse ASCII characters instead of emoji
--savedUse a previously saved connection
--helpShow help
--versionShow version

Environment Variables

VariableDescription
DATABASE_URLFallback connection URI when no arguments are provided

Global Install (optional)

npm install -g sqltree
sqltree

Keyboard Shortcuts

Tree Browser

KeyAction
/ kMove up
/ jMove down
Enter / / lExpand node / browse table
/ hCollapse node / go to parent
Tab / sEnter SQL REPL mode
dDescribe table structure
eExport last result to CSV
rRefresh tree
qQuit

Browse Mode

KeyAction
Next page
Previous page
Exit browse
wScroll up
sScroll down

SQL REPL

CommandAction
SQL ending with ;Execute query
\backReturn to tree browser
\export <csv|json>Export last result
\save <name>Save current connection profile
Ctrl+CCancel / return to tree

Saved Connections

Connection profiles are stored in ~/.sqltree/connections.json with file permissions restricted to your user (mode 0600).

⚠️ Warning: Profiles contain passwords in plain text — treat this file as sensitive. Avoid committing it to version control.

Requirements

  • Node.js 20+
  • Network access to your database server

Tutorial

New to sqltree? Check out the Getting Started Tutorial — a step-by-step guide covering installation, connecting, tree navigation, the SQL REPL, exporting, config, and more.

Contributing

See CONTRIBUTING.md for guidelines.

License

MIT

About

Interactive TUI database client for PostgreSQL & MySQL

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages