README
ΒΆ
dbTui β‘π
dbTui is a blazing-fast, ultra-lightweight Terminal Database Client designed for seamless database management directly from your shell. Forget heavy, memory-hogging GUI applicationsβmanage PostgreSQL, MySQL, and SQLite databases instantly with high performance and zero bloat.
Why dbTui? Portable single-binary (~21MB), minimal memory footprint (~16MB idle), fully keyboard-driven, and packed with protective safety guardrails.
β‘ Key Features
- π Multi-Engine Support β Native, high-performance connectors for PostgreSQL, MySQL, and SQLite (CGO-free).
- π¨ Responsive TUI Layout β Clean, color-coded schema explorer showing connection β database β table structure.
- β¨οΈ Keyboard-Driven Workflow β Ergonomic shortcuts, global inputs, and multi-line SQL editor with command history.
- ποΈ Schema Navigator β Seamlessly explore columns, data types, indexes, and foreign keys without manual metadata queries.
- π οΈ Visual Table Creator β Interactive form to build tables including column definitions, types, nullability, primary keys, and auto-increment.
- π‘οΈ Built-in Safety Guardrails β Automated 1000-row limit safety to prevent Out-Of-Memory (OOM) crashes, along with protective execution timeouts.
- πΎ Self-Healing Config β All database profiles are stored in
~/.dbTui/config.json. Auto-repairs duplicate or corrupt connection IDs on startup. - π Universal Clipboard Integration β Copy table/column/cell data to system clipboard. Features OSC 52 terminal copy fallback if no clipboard utility (
xclip/wl-copy) is installed. - π€ Export to CSV β Instantly save query results to a CSV file with a single keyboard shortcut.
π¦ Installation & Distribution
1. Using go install (Fastest for Go Developers)
If you have Go 1.23+ installed, build and install the binary directly to your $GOPATH/bin with:
go install github.com/farhank15/dbTui/cmd/dbTui@latest
2. Using Automated Installer Script (curl | sh)
For Linux and macOS users, install dbTui instantly without installing Go or manual configuration:
curl -sSfL https://raw.githubusercontent.com/farhank15/dbTui/main/install.sh | sh
This script auto-detects your OS and CPU architecture, downloads the latest pre-built binary release, and installs it into /usr/local/bin (falls back to ~/.local/bin if run without root privileges).
3. Pre-Compiled Binaries (No Source Code)
Download pre-compiled binaries from the GitHub Releases page:
- Go to the repository's Releases page.
- Download the archive for your OS (e.g.
dbTui_Linux_x86_64.tar.gzordbTui_Windows_x86_64.zip). - Extract and place the binary in your system
PATH(e.g.,/usr/local/binorC:\Windows\system32).
4. Build from Source
# Clone the repository
git clone https://github.com/farhank15/dbTui
cd dbTui
# Clean and download dependencies
go mod tidy
# Run directly
go run ./cmd/dbTui
# Build local binary
go build -o dbTui ./cmd/dbTui
β¨οΈ Keyboard Shortcuts
π Global Navigation
| Shortcut | Function |
|---|---|
Tab |
Switch focus between panels (Sidebar β Query Editor β Result Table) |
Esc |
Return focus to Sidebar / Close active modal dialog |
Ctrl + N |
Open "New Connection" form dialog |
Ctrl + D |
Disconnect the currently active database connection |
Ctrl + H |
Toggle active help information modal |
F5 |
Refresh the explorer tree sidebar |
π Explorer Sidebar
| Shortcut | Function |
|---|---|
β / β |
Select connection, database, or table nodes |
β / β |
Expand / Collapse directories |
Enter |
Connect/Disconnect or load table structure detail |
/ |
Filter tables in database by name |
y / Y |
Copy selected database or table name to system clipboard |
v / V |
View Table DDL / schema DDL |
f / F |
Search table rows matching a specific column value |
d / D |
Disconnect selected connection node |
Delete |
Remove connection from config / Drop database with confirmation modal |
π SQL Query Editor
| Shortcut | Function |
|---|---|
Ctrl + J |
Execute the written SQL query |
Ctrl + P / Ctrl + N |
Cycle backward / forward through query command history |
Ctrl + T |
Open SQL templates / snippets list dialog |
Ctrl + F |
Auto-format SQL query text |
Tab |
Focus results table |
π Result Table
| Shortcut | Function |
|---|---|
β / β / β / β |
Scroll through query results |
Enter |
Inspect/View full cell value in a scrollable modal |
e / E |
Edit selected cell value inline (performs database UPDATE) |
Ctrl + E |
Export active query results to CSV |
/ |
Filter columns by name (when viewing table detail metadata) |
ποΈ Architecture
dbTui enforces clean architectural boundaries separating the TUI presentation layer from driver connectors:
dbTui/
βββ cmd/
β βββ dbTui/main.go # Application Entry Point
βββ internal/
β βββ tui/ # π¨ UI & Event Handlers (tview + tcell)
β β βββ app.go # Central layout orchestrator & global shortcut listener
β β βββ sidebar.go # Tree view schema navigator (Conn β DB β Table)
β β βββ query_panel.go # Multi-line SQL text editor
β β βββ result_table.go # Query result grid & metadata details viewer
β β βββ dialogs.go # Form modals: new connection, table creator, confirms
β βββ db/ # ποΈ Thread-Safe Database Drivers
β β βββ connector.go # Universal driver interface
β β βββ postgres.go # PostgreSQL adapter (via pgx)
β β βββ mysql.go # MySQL adapter (via go-sql-driver)
β β βββ sqlite.go # SQLite CGO-Free adapter
β βββ config/ # βοΈ Configuration Manager
β βββ config.go # JSON parser with unique ID Self-Healing validation
π‘οΈ Safety & Stability Features
| Feature | Technical Detail |
|---|---|
| Row Limit Safety | Restricts MaxDisplayRows = 1000 to prevent terminal memory exhaust (OOM) on massive tables. |
| Query Timeout | Automatic query execution timeout at 30 seconds to prevent hanging zombie database processes. |
| Connection Locks | Safe concurrency operations under multiple background tasks using sync.RWMutex. |
| Self-Healing Config | Automatically detects and repairs overlapping connection IDs in config.json on app startup. |
| OSC 52 Clipboard | Copy data natively even on headless servers/containers or SSH sessions without xclip. |
π Feature Comparison
| Feature / Metric | dbTui β‘ | DBeaver | lazysql | usql |
|---|---|---|---|---|
| Interface | TUI (Terminal) | GUI (Desktop) | TUI (Terminal) | CLI (Command Line) |
| Binary Size | ~21 MB | >300 MB | ~15 MB | ~25 MB |
| RAM (Idle) | ~16 MB | >500 MB | ~20 MB | ~10 MB |
| PostgreSQL & MySQL | β | β | β | β |
| SQLite (CGO-free) | β | β | β | β |
| Visual Table Creator | β | β | β | β |
| CSV Exporter | β | β | β | β |
| Auto-Healing Config | β | β | β | β |
π License
Distributed under the MIT License. See the LICENSE file for more information.
Built with β€οΈ using Go and tview. Fast, lightweight, and robust on any system!