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