| Crates.io | pgpeek |
| lib.rs | pgpeek |
| version | 1.0.0 |
| created_at | 2025-08-16 14:22:23.228115+00 |
| updated_at | 2025-08-16 14:22:23.228115+00 |
| description | peek into postgres without the hassle |
| homepage | |
| repository | https://github.com/simplysabir/pgpeek |
| max_upload_size | |
| id | 1798518 |
| size | 185,198 |
┌─────────────────────────────────────────────────────────────────┐
│ │
│ 🔍 P G P E E K │
│ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │
│ │
│ 📊 Connect • 🔍 Browse • ⚡ Query │
│ │
│ Database exploration that doesn't suck │
│ No complex setup, no bullshit - just peek into your data │
│ │
└─────────────────────────────────────────────────────────────────┘
peek into postgres without the hassle
cargo install pgpeek
# Initialize pgpeek
pgpeek init
# Add your database
pgpeek add local postgres://user:pass@localhost:5432/mydb --default
# Start exploring
pgpeek explore
When you run pgpeek without arguments, you'll see:
🔍 pgpeek
┌─────────────────────────────────────────┐
│ Database exploration that doesn't suck │
└─────────────────────────────────────────┘
📊 Connect • 🔍 Browse • ⚡ Query
Quick start:
• pgpeek init → setup config
• pgpeek add <name> <url> → add database
• pgpeek explore → start explorer
When starting the explorer:
┌─ 🔍 pgpeek explorer ─┐
│ │
│ 🚀 Connecting to: │
│ mydb │
│ │
│ ⏳ Loading schemas │
└──────────────────────┘
⠋ Connecting to database...
✓ Connected successfully!
Inside the TUI, you'll see a clean interface:
┌─────────────────────── 🔍 pgpeek ────────────────────────┐
│ 📊 local → postgres://user@localhost:5432/mydb │
└──────────────────────────────────────────────────────────┘
┌── 📈 Database Overview ────────────────────────────────┐
│ Database: mydb │
│ Size: 125 MB │
│ Tables: 47 │
│ Schemas: 3 │
│ User: postgres │
└────────────────────────────────────────────────────────┘
┌─── 📂 Schemas ─────────────────────────────────────────┐
│ ▶ 📁 public (34 tables) │
│ 📁 auth (8 tables) │
│ 📁 analytics (5 tables) │
└────────────────────────────────────────────────────────┘
┌────────────────────────────────────────────────────────┐
│ Status: Database overview loaded - 3 schemas │
│ Help: 1=Overview 2=Schemas 3=Tables 4=Query q=Quit │
└────────────────────────────────────────────────────────┘
# Add connections
pgpeek add prod postgres://user:pass@prod-db.com:5432/app
pgpeek add staging postgres://user:pass@staging.com:5432/app_staging
# List all connections
pgpeek list
# Test a connection
pgpeek test prod
# Remove a connection
pgpeek remove old_db
# Start the interactive explorer
pgpeek explore # uses default connection
pgpeek explore prod # use specific connection
Once the explorer opens, you can navigate with these controls:
Main Navigation (available anywhere):
1 - Database overview (size, table count, connection info)2 - Browse schemas (list all schemas with table counts)3 - Browse all tables (across all schemas or within selected schema)4 - Open SQL query editor5 - Saved queries (manage your stored queries)r - Refresh current view/dataq - Quit pgpeekCtrl+C - Force quitList Navigation:
↑/↓ Arrow keys - Navigate up/down in lists (schemas, tables)Enter - Select item and drill down (e.g., select schema → view its tables)Esc - Exit current mode and return to normal navigationQuery Editor Mode:
4 - Enter query editor modeEsc - Exit editing mode (keeps your query text)Enter - Execute the current query↑/↓ Arrow keys - Navigate through query historyBackspace - Delete charactersSample Data & Results:
Quick Tips:
1-5) from anywhere to jump directly to that sectionEsc to get out of any editing moder to force refreshpgpeek stores configuration in ~/.config/pgpeek/config.toml:
[settings]
page_size = 100
auto_refresh = false
theme = "default"
show_row_numbers = true
query_history_size = 50
[connections]
[connections.local]
name = "Local Development"
host = "localhost"
port = 5432
database = "myapp_dev"
username = "postgres"
password = "secret"
[connections.prod]
name = "Production"
host = "prod-db.example.com"
port = 5432
database = "myapp"
username = "app_user"
ssl_mode = "require"
[saved_queries]
[saved_queries.active_users]
name = "Active Users"
description = "Users active in last 30 days"
sql = "SELECT COUNT(*) FROM users WHERE last_login > NOW() - INTERVAL '30 days'"
created_at = "2024-01-15T10:30:00Z"
connection = "prod"
-- Simple table exploration
SELECT * FROM users LIMIT 10;
-- Filter and search
SELECT * FROM orders WHERE status = 'pending' ORDER BY created_at DESC;
-- Aggregations
SELECT country, COUNT(*) as user_count
FROM users
GROUP BY country
ORDER BY user_count DESC;
SHOW TABLES - List all tablesDESCRIBE users - Show table structureEXPLAIN SELECT * FROM orders - Query execution plan# Basic connection
postgres://username:password@hostname:port/database
# With SSL
postgres://user:pass@host:5432/db?sslmode=require
# Local development
postgres://postgres@localhost/myapp
# Production with SSL
postgres://app_user:secret@prod.db.com:5432/app?sslmode=require
LIMIT for large tablesCreate reusable queries for common operations:
# In the query editor, save useful queries
# They'll be stored in your config and accessible via the saved queries menu
# Set up different environments
pgpeek add local postgres://postgres@localhost/myapp_dev
pgpeek add staging postgres://user:pass@staging.db.com/myapp
pgpeek add prod postgres://user:pass@prod.db.com/myapp --default
# Quick switching
pgpeek explore local
pgpeek explore staging
pgpeek explore prod
# Test all connections
for conn in $(pgpeek list --names-only); do
echo "Testing $conn..."
pgpeek test "$conn"
done
# Test your connection first
pgpeek test mydb
# Check connection details
pgpeek show mydb
# Common issues:
# - Wrong credentials
# - SSL configuration
# - Network connectivity
# - Database permissions
LIMIT clausesEXPLAIN# Reset configuration
rm ~/.config/pgpeek/config.toml
pgpeek init
# Backup your config
cp ~/.config/pgpeek/config.toml ~/pgpeek-backup.toml
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)# Clone and build
git clone https://github.com/simplysabir/pgpeek.git
cd pgpeek
cargo build
# Run tests
cargo test
# Run locally
cargo run -- init
cargo run -- add local postgres://postgres@localhost/test
cargo run -- explore
Get pgpeek up and running locally with Docker in just a few commands:
git clone https://github.com/simplysabir/pgpeek.git
cd pgpeek
# Start PostgreSQL database with sample data
docker-compose up -d postgres
# Build and run pgpeek
docker-compose build pgpeek
docker-compose run --rm pgpeek
# Initialize pgpeek configuration
docker-compose run --rm pgpeek init
# Add the test database connection
docker-compose run --rm pgpeek add testdb postgres://pgpeek_user:pgpeek_pass@postgres:5432/testdb --default
# Start exploring the test database
docker-compose run --rm pgpeek explore
For active development with hot reload:
# Start development environment with source code mounted
docker-compose up -d postgres
docker-compose run --rm pgpeek-dev bash
# Inside the container:
cargo build # Build the project
cargo run # Run pgpeek
cargo test # Run tests
cargo watch -x run # Auto-reload on changes
The docker-compose setup includes:
postgres: PostgreSQL 15 with sample data
testdbpgpeek_user / Password: pgpeek_pass5432users, sales, inventorypgpeek: Production build of pgpeek
pgpeek-dev: Development environment
The test database includes realistic sample data:
📂 Schemas:
├── users (profiles, sessions)
├── sales (customers, orders, order_items, order_summary view)
├── inventory (categories, products, stock)
└── public (default schema)
📊 Sample Data:
• 5 user profiles with recent login activity
• 4 customers from different countries
• 5 orders with various statuses
• 5 products across different categories
• Stock data across multiple warehouses
# Build images
docker-compose build
# Start just the database
docker-compose up -d postgres
# Run pgpeek commands
docker-compose run --rm pgpeek [command]
docker-compose run --rm pgpeek init
docker-compose run --rm pgpeek list
docker-compose run --rm pgpeek explore testdb
# Development environment
docker-compose run --rm pgpeek-dev bash
# Clean up
docker-compose down
docker-compose down -v # Remove volumes too
If you prefer running without Docker:
# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Build and run
cargo build --release
./target/release/pgpeek init
./target/release/pgpeek add local postgres://user:pass@localhost:5432/mydb
./target/release/pgpeek explore
MIT - Use it, abuse it, whatever. Just keep peeking! 🔍
Built with ❤️ in Rust
Because database exploration shouldn't be painful.