Skip to content

logicalangel/SqlTree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

41 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

🌳 sqltree

npm version License: MIT Node.js Tests Coverage Buy Me A Coffee Tutorial

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

Flag Description
--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)
--ssl Enable SSL for the connection
--ssl-reject-unauthorized <bool> Verify SSL certificates (default: true)
--ascii Use ASCII characters instead of emoji
--saved Use a previously saved connection
--help Show help
--version Show version

Environment Variables

Variable Description
DATABASE_URL Fallback connection URI when no arguments are provided

Global Install (optional)

npm install -g sqltree
sqltree

Keyboard Shortcuts

Tree Browser

Key Action
↑ / k Move up
↓ / j Move down
Enter / β†’ / l Expand node / browse table
← / h Collapse node / go to parent
Tab / s Enter SQL REPL mode
d Describe table structure
e Export last result to CSV
r Refresh tree
q Quit

Browse Mode

Key Action
↓ Next page
↑ Previous page
← Exit browse
w Scroll up
s Scroll down

SQL REPL

Command Action
SQL ending with ; Execute query
\back Return to tree browser
\export <csv|json> Export last result
\save <name> Save current connection profile
Ctrl+C Cancel / 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

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors