DBCrust
The modern database CLI that speaks your language
PostgreSQL • MySQL • SQLite with zero compromises
[PyPI : pypi.org] [GitHub : github.com] [MIT License : opensource.org] [Rust 2024 : blog.rust-lang.org]
🚀 Why DBCrust?¶
DBCrust revolutionizes database interaction by combining the speed of Rust with the simplicity of modern CLIs. Whether you're debugging production issues, analyzing data, or automating workflows, DBCrust provides an unmatched developer experience.
One Tool, All Databases
Stop juggling between psql
, mysql
, and sqlite3
. DBCrust speaks all three languages fluently.
✨ Features That Matter¶
Context-Aware Autocompletion
SELECT id, na[TAB] → name, email, created_at
FROM us[TAB] → users, user_sessions, user_preferences
WHERE st[TAB] → status, state, start_date
Smart URL Scheme Completion
dbc pos[TAB] → postgres://
dbc docker://my[TAB] → docker://my-postgres-container
dbc session://prod[TAB] → session://production_db
Beautiful Query Visualization
SSH Tunneling Made Simple
# Automatic tunnel detection
dbcrust postgres://user@db.internal.company.com/prod
# → Automatically routes through configured jumphost
HashiCorp Vault Integration
Docker Integration
# Interactive container selection
dbcrust docker://
# → 1. postgres-dev (postgres:15)
# 2. mysql-test (mysql:8.0)
# 3. redis-cache (redis:7)
# Direct container access with autocompletion
dbcrust docker://post[TAB] → docker://postgres-dev
OrbStack Support
Seamless API
import dbcrust
# Execute queries directly
result = dbcrust.run_command(
"postgres://user@localhost/db",
"SELECT * FROM users LIMIT 10"
)
# Launch interactive CLI
dbcrust.run_cli("postgres://user@localhost/db")
Django ORM Analyzer
from dbcrust.django import analyzer
# Detect N+1 queries and optimization opportunities
with analyzer.analyze() as analysis:
books = Book.objects.all()
for book in books:
print(book.author.name) # Will detect N+1
results = analysis.get_results()
print(results.summary) # Performance insights
Rich Client Class
🏃♂️ Quick Start¶
Unix (macOS, Linux):
Windows:
Then use immediately:
🎯 Real-World Examples¶
Database Administration¶
-- List all databases
\l
-- Show table sizes
SELECT schemaname,
tablename,
pg_size_pretty(pg_total_relation_size(schemaname || '.' || tablename)) as size
FROM pg_tables
WHERE schemaname = 'public'
ORDER BY pg_total_relation_size(schemaname||'.'||tablename) DESC;
Performance Analysis¶
-- Toggle EXPLAIN mode
\e
-- Now all queries show execution plans
SELECT u.email, COUNT(o.id) as order_count
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE u.created_at > '2024-01-01'
GROUP BY u.email
HAVING COUNT(o.id) > 5;
DevOps Workflows¶
# Production database health check
dbcrust vault://readonly@prod/postgres-main \
--query "SELECT version(), current_database(), current_user"
# Backup verification
dbcrust postgres://backup-user@replica.db.internal/app \
--ssh-tunnel jumphost.company.com \
--query "SELECT MAX(created_at) FROM critical_table"
🎨 What Makes DBCrust Special?¶
Modern CLI Experience¶
- Syntax highlighting for SQL and output
- History search with fuzzy matching
- External editor support for complex queries
- Session management with saved sessions and connection history
- Smart URL schemes with
docker://
,session://
,recent://
,vault://
- Shell autocompletion for connection URLs and contextual suggestions
Intelligent Features¶
- Named queries with parameter substitution
- Automatic paging for large result sets
- Copy-paste friendly output formats
- Error highlighting with helpful suggestions
Built for Speed¶
- Rust performance - start in milliseconds
- Efficient rendering - handle millions of rows
- Smart caching - autocompletion data persists
- Minimal memory footprint
🛡️ Security First¶
- ✅ TLS/SSL encryption by default
- ✅ SSH key authentication support
- ✅ Password-free workflows via Vault
- ✅ No plaintext storage of credentials
- ✅ Audit logging for compliance
🌟 Community & Support¶
- Documentation
Comprehensive guides and API reference
- Source Code
Open source on GitHub with MIT license
- PyPI Package
Install via pip or uv package manager
- Support
Get help via GitHub issues