DBCrust
High-performance database CLI for developers
Multi-database support • SSH tunneling • Vault integration • Advanced ORM analysis
[PyPI : pypi.org] [GitHub : github.com] [MIT License : opensource.org] [Rust 2024 : blog.rust-lang.org]
🚀 Why DBCrust?¶
A modern database CLI that speaks your language. DBCrust combines the speed of Rust with intelligent features like context-aware autocompletion, SSH tunneling, Vault integration, and powerful Django ORM analysis. Whether you're debugging production issues, analyzing data, or optimizing applications, DBCrust provides an unmatched developer experience.
One Tool, All Databases + Advanced Features
PostgreSQL • MySQL • SQLite • ClickHouse • MongoDB with smart autocompletion • SSH tunneling for secure connections • Vault integration for dynamic credentials • Django ORM analyzer for performance optimization
✨ Core Features¶
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 mo[TAB] → mongodb://
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
📖 Complete SSH Tunneling Guide →
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
📖 Complete Docker Integration Guide →
Session Management
Real-Time N+1 Query Detection
from dbcrust.django import analyzer
with analyzer.analyze() as analysis:
# Your Django code
books = Book.objects.all()
for book in books:
print(f"{book.title} by {book.author.name}") # N+1 detected!
results = analysis.get_results()
print(results.optimization_suggestions)
Performance Insights
🚨 N+1 Query Detected (CRITICAL):
Query: SELECT * FROM books_book
Followed by: 25x SELECT * FROM authors_author WHERE id = ?
💡 Fix: books = Book.objects.select_related('author').all()
Performance: 156ms → 12ms (92% improvement)
Django Management Integration
MongoDB with SQL-like Interface
-- Familiar SQL syntax that translates to MongoDB
SELECT * FROM users WHERE name LIKE 'John%' AND age > 18;
-- Advanced filtering with SQL operators
SELECT * FROM orders WHERE status IN ('pending', 'shipped')
AND total BETWEEN 100 AND 1000;
-- Database management with SQL commands
CREATE DATABASE analytics;
CREATE COLLECTION user_events;
🏃♂️ Quick Start¶
Unix (macOS, Linux):
Windows:
Then use immediately:
🎯 First Connection¶
# PostgreSQL
dbcrust postgres://user:pass@localhost/myapp
# MySQL
dbcrust mysql://root:pass@localhost:3306/myapp
# SQLite
dbcrust sqlite:///./myapp.db
# ClickHouse
dbcrust clickhouse://user:pass@localhost:8123/myapp
# MongoDB
dbcrust mongodb://user:pass@localhost:27017/myapp
dbcrust mongodb+srv://user:pass@cluster.mongodb.net/myapp
# Docker containers (with auto-discovery)
dbcrust docker://my-postgres-container
dbcrust docker://my-mongo-container
dbcrust docker:// # Interactive selection
# Saved sessions
dbcrust session://production_db
🐍 Django Quick Start¶
For Django developers, DBCrust provides specialized ORM analysis tools:
# Install in your Django project
pip install dbcrust
# Connect using Django settings
cd your_django_project/
python manage.py dbcrust
# Test N+1 detection
python manage.py shell
# In Django shell
from dbcrust.django import analyzer
with analyzer.analyze() as analysis:
for post in Post.objects.all():
print(post.author.name) # N+1 detected!
print(analysis.get_results().summary)
📖 Complete Django Setup Guide →
🎯 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¶
- :material-book-open-page-variant:{ .lg .middle } Documentation
Comprehensive guides and API reference
:octicons-arrow-right-24: Explore docs
- :material-github:{ .lg .middle } Source Code
Open source on GitHub with MIT license
:octicons-arrow-right-24: View source
- :material-package-variant:{ .lg .middle } PyPI Package
Install via pip or uv package manager
:octicons-arrow-right-24: Install now
- :material-chat-question:{ .lg .middle } Support
Get help via GitHub issues
Built with ❤️ using Rust, SQLx, and reedline
🤖 Proudly crafted with Claude Code — where AI meets thoughtful development.