A fast, keyboard-driven TUI (Terminal User Interface) for managing PostgreSQL databases with Neovim integration.
LazyDB brings the power and convenience of terminal-based database management with vim-style navigation, environment-based connection organization, and automatic query logging.
- 🎯 3-Panel TUI: Connections | Editor | Results
- ⌨️ Vim-style Navigation: Full keyboard control with hjkl movement
- 🔌 PostgreSQL Support: Connect and query PostgreSQL databases
- 📝 Neovim Integration: Edit complex queries in your favorite editor (Ctrl+E)
- 🌍 Environment-Based Organization: Organize connections by Development/Staging/Production
- 🔐 Encrypted Storage: AES-256-GCM password encryption for connection credentials
- 📜 Automatic Query History: Per-environment monthly query logs
- ❓ PostgreSQL Quick Reference: Built-in help with common queries (Press
?) - 🗂️ Schema Explorer: Browse schemas, tables, views, functions, and columns
- ✅ Multi-line SQL editor
- ✅ Execute queries with
Ctrl+R - ✅ Auto-save query history by environment
- ✅ Syntax-highlighted results table
- ✅ Scrollable results with vim bindings
- ✅ Add/Edit/Delete connections
- ✅ Group by environment (Dev/Staging/Prod)
- ✅ Visual connection status indicators
- ✅ Persistent connection storage
- ✅ Encrypted password storage
- ✅ Browse database schemas, tables, views, and functions
- ✅ Expandable tree navigation with vim bindings
- ✅ Real-time search/filter with
/key - ✅ View table column details (type, nullable, default)
- ✅ One-key table preview (SELECT * LIMIT 10)
- ✅ Lazy loading for optimal performance
# Clone the repository
git clone https://github.com/yourusername/lazydb.git
cd lazydb
# Build
go build -o lazydb cmd/lazydb/main.go
# Install (optional)
sudo mv lazydb /usr/local/bin/- Go 1.21 or higher
- PostgreSQL database (for testing)
- Neovim (optional, for advanced editing)
-
Launch LazyDB
./lazydb
-
Add Your First Connection
- Press
1to focus Connections panel - Press
ato add a new connection - Fill in the form:
- Name:
dev-local - Host:
localhost - Port:
5432 - Database:
postgres - Username:
postgres - Password:
your-password - SSL Mode:
disable - Environment: Use
←/→to selectDevelopment
- Name:
- Press
Enterto save
- Press
-
Connect to Database
- Select your connection with
j/k - Press
Enterto connect
- Select your connection with
-
Run Your First Query
- Press
2to focus Editor panel - Type a query:
SELECT * FROM pg_database; - Press
Ctrl+Rto execute - Results appear in the right panel
- Press
| Key | Action |
|---|---|
1, 2, 3 |
Focus panel (Connections, Editor, Results) |
Tab |
Cycle to next panel |
Shift+Tab |
Cycle to previous panel |
? or F1 |
Open PostgreSQL help reference |
q or Ctrl+C |
Quit application |
| Key | Action |
|---|---|
j / ↓ |
Move down |
k / ↑ |
Move up |
Enter |
Connect to selected database |
a |
Add new connection |
e |
Edit selected connection |
d |
Delete selected connection |
s |
Open schema explorer |
| Key | Action |
|---|---|
j / ↓ |
Move down |
k / ↑ |
Move up |
Enter / Space |
Expand/collapse node |
/ |
Enter search mode |
r |
Refresh schema from database |
p |
Preview table (SELECT * LIMIT 10) |
Esc |
Exit search / Return to connections |
In Search Mode:
| Key | Action |
|---|---|
| Type characters | Filter results in real-time |
Backspace |
Delete last character |
j / k |
Navigate filtered results |
Enter |
Expand/collapse node |
p |
Preview table |
Esc |
Clear search and exit |
| Key | Action |
|---|---|
Ctrl+R |
Execute query |
Ctrl+E |
Open in Neovim |
F2 |
Save query to file |
| Key | Action |
|---|---|
j / ↓ |
Scroll down |
k / ↑ |
Scroll up |
h / ← |
Scroll left |
l / → |
Scroll right |
| Key | Action |
|---|---|
←/→ |
Switch category |
↑/↓ |
Navigate queries |
Enter |
Copy query to editor |
Esc / ? |
Close help |
LazyDB stores its configuration and data in ~/.lazydb/:
~/.lazydb/
├── connections.json # Encrypted connection configs
└── queries/
├── Development_2025-01.sql # January dev queries
├── Staging_2025-01.sql # January staging queries
└── Production_2025-01.sql # January production queries
Each executed query is automatically logged:
-- Executed on: 2025-01-15 14:30:45 (Development)
SELECT * FROM users WHERE active = true;
-- Executed on: 2025-01-15 15:22:10 (Development)
UPDATE products SET price = price * 1.1;- Password Encryption: All database passwords are encrypted using AES-256-GCM before storage
- File Permissions: Config files are stored with
0600permissions (user read/write only) - Key Derivation: Encryption key derived from username + static salt using SHA-256
go test ./tests/unit/... -vRequires a running PostgreSQL instance:
# Start test database
docker run --name test-postgres \
-e POSTGRES_PASSWORD=postgres \
-p 5432:5432 -d postgres
# Run tests
TEST_POSTGRES_DSN="postgres://postgres:postgres@localhost:5432/postgres" \
go test ./tests/integration/... -v- PostgreSQL support
- Connection management
- Query execution
- Neovim integration
- Environment organization
- Password encryption
- Query history logging
- Help reference dialog
- Schema explorer (schemas, tables, views, functions, columns)
- Table preview functionality
- MySQL support
- SQLite support
- Query library with templates
- Export results (CSV, JSON, SQL)
- Query history viewer
- Transaction support
- Query cancellation
- Custom themes
- Configurable keybindings
- Multi-tab support
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - see LICENSE file for details
Built with:
- Bubble Tea - TUI framework
- Lipgloss - Terminal styling
- pgx - PostgreSQL driver
Inspired by:
- GitHub: @yourusername
- Issues: GitHub Issues
Made with ❤️ for developers who live in the terminal