| Crates.io | pg-tui |
| lib.rs | pg-tui |
| version | 0.1.0 |
| created_at | 2026-01-20 19:26:39.724895+00 |
| updated_at | 2026-01-20 19:26:39.724895+00 |
| description | A modern PostgreSQL TUI client with autocomplete, syntax highlighting, and query formatting |
| homepage | https://github.com/notcool100/pg-tui |
| repository | https://github.com/notcool100/pg-tui |
| max_upload_size | |
| id | 2057347 |
| size | 170,975 |
A modern, feature-rich terminal user interface (TUI) for PostgreSQL with DBeaver-like functionality, written in Rust.
;users. to see columns from users tablegit clone <repository-url>
cd psql_cli
cargo build --release
The optimized binary will be at target/release/psql_cli.
cargo install --path .
./target/release/psql_cli
| Key | Action |
|---|---|
↑ / ↓ |
Navigate saved connections |
Enter |
Select connection |
n |
New connection |
d |
Delete selected connection |
q |
Quit |
| Key | Action |
|---|---|
↑ / ↓ |
Navigate schemas/tables |
Enter |
Expand schema or view table details |
Tab |
Switch to query mode |
r |
Refresh browser |
q |
Quit |
| Key | Action |
|---|---|
Ctrl+Enter / F5 |
Execute query at cursor |
Alt+Shift+F |
Format/beautify query |
Tab |
Switch to browser mode |
Ctrl+F |
Filter results |
Shift+←/→ |
Scroll results horizontally |
q |
Quit (when editor is empty) |
| Key | Action |
|---|---|
| Type to trigger | Show suggestions |
↑ / ↓ |
Navigate suggestions |
Tab |
Accept selected suggestion |
Esc |
Dismiss autocomplete |
Write multiple queries in the editor:
SELECT * FROM users;
SELECT * FROM orders WHERE status = 'active';
SELECT COUNT(*) FROM products;
Place cursor anywhere in a query and press Ctrl+Enter - only that query executes!
Keywords:
SEL → suggests SELECT
FRO → suggests FROM
Tables:
SELECT * FROM use → suggests users, user_sessions
Columns:
SELECT id, na → suggests name, name_first, name_last
Table.Column:
users. → shows all columns from users table
users.em → suggests email
Before:
select id,name,email from users where age>18 and status='active' order by created_at desc;
After (Alt+Shift+F):
SELECT
id,
name,
email
FROM users
WHERE age > 18
AND status = 'active'
ORDER BY created_at DESC;
psql_cli/
├── src/
│ ├── main.rs # Application entry point
│ ├── app.rs # State management
│ ├── autocomplete.rs # SQL autocomplete engine
│ ├── formatter.rs # SQL query formatter
│ ├── syntax.rs # Syntax highlighting
│ ├── config.rs # Connection profiles
│ ├── db/ # Database layer
│ │ ├── connection.rs # PostgreSQL connection
│ │ ├── queries.rs # SQL queries
│ │ └── mod.rs
│ └── ui/ # UI components
│ ├── browser.rs # Database browser
│ ├── query.rs # Query editor
│ ├── connection.rs # Connection screen
│ └── mod.rs
└── Cargo.toml
| Feature | psql_cli | DBeaver |
|---|---|---|
| SQL Autocomplete | ✅ | ✅ |
| Syntax Highlighting | ✅ | ✅ |
| Query Formatting | ✅ | ✅ |
| Smart Execution (cursor) | ✅ | ✅ |
| Terminal-based | ✅ | ❌ |
| Lightweight | ✅ (~MB) | ❌ (~100MB) |
| Fast Startup | ✅ (~1s) | ❌ (~10s) |
MIT License - see LICENSE file for details
Inspired by:
Contributions are welcome! Please feel free to submit a Pull Request.
Found a bug? Please open an issue.
Built with ❤️ using Rust and Ratatui