Skip to main content

High-performance database CLI engineered for Django developers — Advanced ORM analysis, performance optimization, SSH tunneling, and seamless multi-database support (PostgreSQL, MySQL, SQLite)

Project description

DBCrust

One fast client for every database. PostgreSQL, MySQL, SQLite, ClickHouse, MongoDB, Elasticsearch — and SQL over Parquet, CSV, and JSON files. Built in Rust, with an AI assistant, smart autocompletion, SSH tunneling, Vault integration, and a desktop GUI.

CI PyPI Documentation License: MIT

curl -fsSL https://clement-tourriere.github.io/dbcrust/install.sh | sh
dbcrust postgres://user:pass@localhost/mydb

Documentation · Quick start · Command reference · Python API

Why DBCrust

  • Every database, one tool — the same REPL, commands, and muscle memory across PostgreSQL, MySQL, SQLite, ClickHouse, MongoDB, and Elasticsearch.
  • AI assistant built in — type ?? top 10 customers by revenue and get SQL generated from your actual schema, shown before it runs. Works with Anthropic, OpenAI, Gemini, Ollama, and 20+ other providers.
  • Files are databases too — run SQL directly on Parquet, CSV, and JSON via Apache DataFusion.
  • Production-friendly plumbing — SSH tunnels (with auto-tunnel patterns), HashiCorp Vault dynamic credentials, Docker container auto-discovery, encrypted password storage.
  • A REPL that helps — context-aware autocompletion, syntax highlighting, history search, external editor, EXPLAIN visualization (including an interactive TUI), named queries, saved sessions.
  • Scriptable and embeddable-c for one-shot queries, a Python API powered by the same Rust core, and a Django ORM performance analyzer.

Install

# Pre-built binary — macOS & Linux
curl -fsSL https://clement-tourriere.github.io/dbcrust/install.sh | sh

# Pre-built binary — Windows (PowerShell)
irm https://clement-tourriere.github.io/dbcrust/install.ps1 | iex

# Python 3.10+ (ships the same native binary)
uv tool install dbcrust          # or: pipx install dbcrust / pip install dbcrust
uvx dbcrust <url>                # run without installing

# From source (Rust 1.85+)
cargo install --path .

Two binaries are installed: dbcrust and the short alias dbc.

dbcrust --update                 # self-update (detects uv / pipx / pip / cargo / binary installs)
dbcrust --completions zsh        # shell completions (bash, zsh, fish, powershell, ...)

Quick start

dbcrust postgres://user:pass@localhost/mydb     # interactive session
dbcrust recent://                               # pick from recent connections
dbcrust sqlite:///path/to/db.sqlite -c "SELECT count(*) FROM users"   # run and exit

Every connection type is a URL:

Scheme Example
PostgreSQL postgres://user:pass@localhost:5432/mydb?sslmode=require
MySQL mysql://root:pass@localhost:3306/mydb
SQLite sqlite:///path/to/db.sqlite
ClickHouse clickhouse://user:pass@localhost:8123/default
MongoDB mongodb://user:pass@localhost:27017/mydb
Elasticsearch elasticsearch://localhost:9200
Parquet / CSV / JSON parquet:///data/*.parquet · csv:///logs/app.csv?header=true · json:///events.json
Docker container docker:// (interactive picker) · docker://my-postgres/mydb
Saved session session://production_db
Recent connections recent://
Vault credentials vault://readonly@database/postgres-prod

Full details: URL schemes reference.

The interactive session

Connecting drops you into a REPL with context-aware SQL autocompletion, syntax highlighting, searchable history, and 60+ psql-style backslash commands. The most used:

Commands
Explore \l databases · \c <db> switch · \dt tables · \d <table> describe
Display \x expanded · \cs column selection · \e EXPLAIN mode · \ev interactive EXPLAIN TUI
Edit & run \ed open $EDITOR · \i <file> run SQL file · \w <file> write last query
Named queries \n list · \ns <name> <sql> save · \nd <name> delete
Connections \ss <name> save session · \s list sessions · \r recent · \docker containers
Credentials \savepass store password · \vc Vault cache status
Meta \ai AI assistant · \config settings editor · \h help · \q quit

Named queries support positional parameters ($1, $*, $@) and scopes — global, per-database-type, or session-local.

See the full command reference.

AI assistant

Turn natural language into SQL without leaving your session. The assistant uses your database's real schema as context, streams its answer, and always shows the SQL before running it (writes default to "No").

\ai setup                                        -- one-time wizard: provider, model, API key

?? top 10 customers by total order value this year
?? now only the active ones                      -- follow-ups keep conversation context
  • Providers: Anthropic, OpenAI, Gemini, Ollama, Groq, DeepSeek, xAI, OpenRouter, and more — 25+ via genai, including any OpenAI-compatible endpoint for self-hosted models.
  • Private by design: disabled by default; only schema metadata and your question are sent — never row data. API keys live in your OS keychain, an encrypted file, or environment variables.

More in the AI assistant guide.

Tunnels, Vault & Docker

SSH tunneling — reach databases behind a jump host, explicitly or automatically via config patterns:

dbcrust postgres://user@db.internal/app --ssh-tunnel jumphost.example.com
# ~/.config/dbcrust/config.toml — auto-tunnel any host matching the pattern
[ssh_tunnel_patterns]
"^db\\.internal\\..*\\.com$" = "user@jumphost.example.com:2222"

HashiCorp Vault — dynamic database credentials with an encrypted local cache: dbcrust vault://readonly@database/postgres-prod.

Dockerdbcrust docker:// lists running database containers and connects without you hunting for ports or credentials.

Python & Django

The Python package wraps the same Rust core via PyO3 — identical URLs, commands, and behavior.

import dbcrust

dbcrust.run_command("postgres://user:pass@localhost/mydb", "SELECT * FROM users LIMIT 5")
dbcrust.run_cli("postgres://user:pass@localhost/mydb")     # full interactive REPL

from dbcrust import PostgresClient
client = PostgresClient(host="localhost", user="postgres", dbname="myapp")
tables = client.list_tables()

The Django integration detects N+1 queries and other ORM performance issues:

# settings.py
MIDDLEWARE = ["dbcrust.django.PerformanceAnalysisMiddleware", ...]

# or analyze a block of code explicitly
from dbcrust.django import analyzer
with analyzer.analyze() as analysis:
    for book in Book.objects.all():
        print(book.author.name)        # N+1 detected
results = analysis.get_results()
python manage.py dbcrust               # connect using your Django DB settings

Guides: Python API · Django analyzer.

Desktop GUI

A Tauri-based desktop app ships in the repo (built from source for now): CodeMirror SQL editor, schema explorer, visual EXPLAIN viewer, Docker discovery, multi-tab queries, and a system tray. See the GUI guide.

mise install && mise run gui:install
mise run gui:dev                       # development (hot-reload)
mise run gui:build                     # production .app / .dmg / .msi

Configuration

Settings live in ~/.config/dbcrust/ by default (override with DBCRUST_CONFIG_DIR=/path/to/dbcrust-config-dir), with user data kept in dedicated files:

File Contents
config.toml App settings (display, limits, SSH patterns, AI, logging, ...)
sessions.toml Saved sessions
recent.toml Recent connections
named_queries.toml Named queries
vault_credentials.enc Encrypted Vault credential cache
~/.dbcrust Stored passwords (pgpass-style)

Edit configuration interactively or from scripts — no connection required:

dbcrust config                         # interactive menu (also \config inside the REPL)
dbcrust config get logging.level
dbcrust config set logging.level debug
dbcrust config edit                    # open config.toml in $EDITOR

Full list of options: configuration reference.

Development

DBCrust uses mise for toolchain and task management — mise install sets up everything (Bun for the GUI, commitizen, etc.).

mise run build:dev        # debug build          mise run build      # release build
mise run test             # cargo test           mise run check      # fmt + lint + test
mise run py:dev           # maturin develop      mise run py:test    # Python tests
mise run gui:dev          # GUI with hot-reload  mise run docs       # docs dev server
src/                Rust core — CLI, REPL, database backends, AI assistant
├── commands.rs     backslash command system (enum + strum)
├── database_*.rs   per-database implementations
└── explain_tui/    interactive EXPLAIN visualizer (ratatui)
gui/                Tauri desktop app (React + TypeScript, Bun)
python/             Python bindings (PyO3 + maturin) and Django integration
docs/               documentation site (Astro Starlight)

More in the development guide.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

dbcrust-0.30.1-cp310-abi3-win_amd64.whl (14.2 MB view details)

Uploaded CPython 3.10+Windows x86-64

dbcrust-0.30.1-cp310-abi3-musllinux_1_2_x86_64.whl (18.4 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

dbcrust-0.30.1-cp310-abi3-musllinux_1_2_aarch64.whl (18.3 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

dbcrust-0.30.1-cp310-abi3-manylinux_2_28_aarch64.whl (18.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

dbcrust-0.30.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.6 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

dbcrust-0.30.1-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (18.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ i686

dbcrust-0.30.1-cp310-abi3-macosx_11_0_arm64.whl (14.8 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

dbcrust-0.30.1-cp310-abi3-macosx_10_12_x86_64.whl (14.6 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file dbcrust-0.30.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: dbcrust-0.30.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 14.2 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for dbcrust-0.30.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8697f1b399310980ffce444f107db365759ad64b0662adc1f214ae27e8a0c763
MD5 92ec3ad21e3ba82a9c007b64aa06be4a
BLAKE2b-256 d20cd9acf0f7ae571a31a733a839ebd2f1abf40881df54da614805b612e9fa10

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbcrust-0.30.1-cp310-abi3-win_amd64.whl:

Publisher: release.yml on clement-tourriere/dbcrust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dbcrust-0.30.1-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for dbcrust-0.30.1-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 706875ad46b019a96f25df9db696c01470f809186d389168acb693502757fd0b
MD5 c88755068abe250c741123f919437519
BLAKE2b-256 0615aa782a6164345f6f4a702ef2d458e5eb78c7225eaf9c19e564a982c30200

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbcrust-0.30.1-cp310-abi3-musllinux_1_2_x86_64.whl:

Publisher: release.yml on clement-tourriere/dbcrust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dbcrust-0.30.1-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for dbcrust-0.30.1-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 30d03b71a99b46b8cb23daded468d6357a4282724e8cf449a1f0091249fcdba9
MD5 45031b5808ae1f97a100577bffeecfad
BLAKE2b-256 79088d074c3239b6d4bb80cf05b90a8d9ca0a79309ccd7c694f084ea46627b14

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbcrust-0.30.1-cp310-abi3-musllinux_1_2_aarch64.whl:

Publisher: release.yml on clement-tourriere/dbcrust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dbcrust-0.30.1-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for dbcrust-0.30.1-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 39bd4f40cd9d28d14745f3e147173640e3220edbf03a6e82cda608cc3867bfdb
MD5 70698b1d442122b727df819008d5ee28
BLAKE2b-256 9945391c5ff9887792077a4e520ae679e1234ece3eae2e6213502b1a162297ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbcrust-0.30.1-cp310-abi3-manylinux_2_28_aarch64.whl:

Publisher: release.yml on clement-tourriere/dbcrust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dbcrust-0.30.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for dbcrust-0.30.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 878680fa05b885750043f493832307ecc54143f4cda513aaa7a035961bd33c9a
MD5 d93c311e94180cca72d6d8babeb945e0
BLAKE2b-256 2054e3c414f0eb359b9c7c6f771e1a9e5735e3db87c5bdacd3b52aa86bdc8458

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbcrust-0.30.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on clement-tourriere/dbcrust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dbcrust-0.30.1-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for dbcrust-0.30.1-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 1b44e91f1dcbac801035ebd9af1876900365a822c15dbdb8aec279e3c00e27f8
MD5 56e5a1d6b51c25dc4af3e238402a92a6
BLAKE2b-256 27fe042a9fb24102cc197b45f405ee85b15b36102fcdb30a00db1ee5232d9406

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbcrust-0.30.1-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl:

Publisher: release.yml on clement-tourriere/dbcrust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dbcrust-0.30.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dbcrust-0.30.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d49013ac10f257cfea314925a76a71a1d1901cfab7c90b5b39f17c494460f39
MD5 6118dcf18febd96f2f041a85286d7f65
BLAKE2b-256 98677ec38d0948287b8c223651d9de2565dbef788546229a65f1ffdad6b7ed6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbcrust-0.30.1-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on clement-tourriere/dbcrust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dbcrust-0.30.1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for dbcrust-0.30.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1b4fa6133ba8590578ed882507b580ceed33b159be3018c0f88667ea5b9fcebe
MD5 d3cdfb66b0d9266858255c69d302b6d2
BLAKE2b-256 999cdc6efc8ef984ea39f2e6eb79a1901c9ad22e1a9a665251c340ad57aaf8c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for dbcrust-0.30.1-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on clement-tourriere/dbcrust

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page