Skip to content

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

○ Execution Time: 1.23 ms • Planning Time: 0.15 ms
Index Scan
│ Optimized lookup using email_idx
│ ○ Duration: 0.96 ms • Cost: 4 • Rows: 1
│   on users using email_idx
│   filter (email = 'user@example.com')
└► id • name • email • created_at

SSH Tunneling Made Simple

# Automatic tunnel detection
dbcrust postgres://user@db.internal.company.com/prod
# → Automatically routes through configured jumphost

HashiCorp Vault Integration

# Dynamic credentials from Vault
dbcrust vault://app-role@database/postgres-prod
# → Fetches credentials automatically

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

# Works with OrbStack DNS
dbcrust postgres://user@postgres.myproject.orb.local/db

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

from dbcrust import PostgresClient

client = PostgresClient(host="localhost", user="postgres")
results = client.execute("SELECT COUNT(*) FROM orders")
tables = client.list_tables()

🏃‍♂️ Quick Start

Unix (macOS, Linux):

curl -fsSL https://clement-tourriere.github.io/dbcrust/install.sh | sh

Windows:

irm https://clement-tourriere.github.io/dbcrust/install.ps1 | iex

Then use immediately:

dbcrust postgres://user:pass@localhost/mydb
dbc postgres://user:pass@localhost/mydb  # Short alias

# Run immediately without installation
uvx dbcrust postgres://user:pass@localhost/mydb

# Or install globally
uv tool install dbcrust
dbcrust --help
pip install dbcrust
dbcrust postgres://user:pass@localhost/mydb
git clone https://github.com/clement-tourriere/pgcrust.git
cd pgcrust
cargo install --path .
dbcrust --help

🎯 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

Explore docs

  • Source Code

Open source on GitHub with MIT license

View source

  • PyPI Package

Install via pip or uv package manager

Install now

  • Support

Get help via GitHub issues

Get support


Ready to supercharge your database workflow?
Get Started in 2 Minutes Learn More

Built with ❤️ using Rust, SQLx, and reedline