Skip to main content

DBCrust

A fast psql-style database workbench for your terminal. One CLI for PostgreSQL, MySQL, SQLite, ClickHouse, MongoDB, Elasticsearch, White Dragon search, Docker databases, Vault-backed connections, and SQL over Parquet/CSV/JSON files — with optional AI, Django ORM analysis, Python bindings, and a desktop GUI.

CI PyPI Documentation License: MIT

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

AI is optional and disabled by default. DBCrust works with zero AI setup. ?? sends schema metadata and your question, not row data; ??? and Django AI investigations can inspect bounded query results. Generated SQL is shown before execution.

Documentation · Quick start · AI/privacy · Django analyzer · Python API

Why DBCrust

  • One workflow across databases — the same REPL, commands, and muscle memory across PostgreSQL, MySQL, SQLite, ClickHouse, MongoDB, and Elasticsearch.
  • Files are databases too — inspect Parquet, CSV, and JSON with SQL via Apache DataFusion, no import step or notebook required.
  • Optional AI you control — type ?? top 10 customers by revenue to generate SQL from schema context, or use ??? for bounded read-only investigations. Supports Anthropic, OpenAI, Gemini, Ollama, and 20+ other providers.
  • DBCrust for Django — catch N+1 queries, missing select_related / prefetch_related, slow views, and index opportunities before production.
  • 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, embeddable, agent-ready — -c/-f/stdin one-shots with -o json|csv output, stable exit codes, a --read-only guard, and a Python API powered by the same Rust core.

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
dbc ./users.csv                                 # infer CSV from the extension
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 or ./path/to/db.sqlite
ClickHouse clickhouse://user:pass@localhost:8123/default
MongoDB mongodb://user:pass@localhost:27017/mydb
Elasticsearch elasticsearch://localhost:9200
White Dragon white-dragon://localhost:7700
Parquet / CSV / JSON ./data.parquet · ./logs/app.csv · file:// picker · 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.

Built for AI agents

Coding agents work best with CLIs they can shell out to — no MCP server to run, no per-tool token overhead, composable with pipes and exit codes. DBCrust's one-shot mode gives them one binary for every data service:

dbcrust session://prod -c '\ddl'                            # whole schema as compact DDL, one call
dbcrust session://prod --read-only --no-input -o json \
  -c "SELECT status, count(*) FROM orders GROUP BY status"  # single-line {"columns","rows",...} envelope
echo "SELECT count(*) FROM logs" | dbcrust ./logs.parquet   # stdin scripts; files are databases too

The contract is built for programmatic callers: results-only stdout (status goes to stderr, the pager never engages), JSON errors on stderr under -o json, stable exit codes (0 ok · 1 SQL error · 2 usage · 3 connection · 4 blocked by --read-only), --timeout/--max-rows limits, and --no-input so no prompt can ever hang an agent. The binary documents itself: run dbcrust agents for the full ~100-line contract, and paste the ready-made snippet into your project's CLAUDE.md/AGENTS.md from the agent quickstart.

--read-only is a best-effort statement guard backed by connect-level hardening (SQLite query_only, PostgreSQL default_transaction_read_only); for hard guarantees use a read-only database role — details in safety & guardrails.

SQL over local files

Inspect production exports, logs, and data drops without importing them into a database or opening a notebook.

dbc warehouse/events.parquet      # inferred from extension
dbc 'logs/*.csv?header=true'      # globs work too
dbc file://                       # interactive compatible-file picker
dbc json:///tmp/api-responses.ndjson
SELECT date_trunc('hour', ts) AS hour, count(*)
FROM events
WHERE level = 'ERROR'
GROUP BY hour
ORDER BY hour DESC;

DBCrust registers matching files as SQL tables and lets DataFusion handle filtering, aggregations, joins, nested JSON fields, and glob patterns. See the file formats guide.

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 · \ddl schema dump
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.
  • Privacy controls: AI is opt-in. ?? sends schema metadata and your prompt/history; query results stay local. ??? and Django "Investigate with AI" can send bounded result rows, query plans, captured SQL, and source context. API keys live in your OS keychain, an encrypted file, or environment variables.

More in the AI assistant guide and privacy notes.

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. An optional AWS-style vault_credential_process can obtain authentication lazily, so ordinary PostgreSQL/MySQL connections never start a Vault login flow. The helper is provider-neutral: any command that prints a token or JSON { "token": "…", "vault_addr": "…" } works.

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

Python API & DBCrust for 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()

DBCrust for Django catches ORM performance bugs before production: N+1 queries, duplicate queries, missing select_related / prefetch_related, slow views, and index opportunities, with recommendations tied back to code locations.

# 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 native, GPU-accelerated desktop app built with GPUI Kit, pure Rust on the same core as the CLI (built from source for now). See the GUI guide.

DBCrust desktop app

  • Connect: one searchable list of saved connections, recent ones and Docker containers, with Test / Save / Connect, environment labels and a Vault wizard. Docker containers connect even when their port isn't published or a VPN blocks the container network: DBCrust relays through Docker itself. Open several connections at once, read-only if you like.
  • Explore: a schema explorer with a cross-connection filter, and a table inspector showing columns, indexes, constraints, references, a data preview and DDL.
  • Edit: a SQL editor with schema-aware completion (aliases and CTEs resolved). Run the statement under the caret, run all, really cancel, format, keep history, and use named queries and .sql files.
  • Results: a virtualized results grid with distinct NULLs and numeric sorting, copy/export as CSV, TSV, JSON or Markdown, and a row inspector.
  • Plans: an EXPLAIN visualizer with plan tree, cost shares, row-estimate checks and recommendations.
  • Navigate: a command palette (⌘K), native menus, full keyboard shortcuts, light/dark themes following the OS plus bundled themes, and drafts that are autosaved and restored.
  • Stays at hand: closing the window keeps DBCrust in the menu bar / system tray with its connections and running queries; reopen or connect from there.

Connect page EXPLAIN visualizer

mise run gui:dev                       # run the app
mise run gui:build                     # release build (target/release/dbcrust-gui)
mise run gui:bundle                    # macOS DBCrust.app

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 2026.8.16+ for toolchain and task management. mise install installs Bun (docs site), Commitizen, and Mr Boxington, which puts a shared, self-pruning cache behind Cargo commands run through mise. No mise? Run ./bin/mise instead of mise: the committed wrapper downloads a pinned mise on first use.

mise install
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          # desktop app         mise run docs       # docs dev server
mise run cache:stats      # mbx cache savings    mbx doctor          # verify the Rust build cache

With mise activated, plain cargo commands use the same cache. Set MBX_DISABLE=1 for a one-off uncached Cargo command.

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/                desktop app (GPUI Kit) — core/ is the GPUI-free backend
python/             Python bindings (PyO3 + maturin) and Django integration
docs/               documentation site (Astro Starlight)

More in the development guide.

License

MIT — see LICENSE.

Metadata

Release files for dbcrust 0.38.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for dbcrust 0.38.0
File
dbcrust-0.38.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
dbcrust-0.38.0-cp310-abi3-musllinux_1_2_x86_64.whl CPython 3.10 abi3 Linux musl 1.2+ x86-64 Details
dbcrust-0.38.0-cp310-abi3-musllinux_1_2_aarch64.whl CPython 3.10 abi3 Linux musl 1.2+ ARM64 Details
dbcrust-0.38.0-cp310-abi3-manylinux_2_28_aarch64.whl CPython 3.10 abi3 Linux glibc 2.28+ ARM64 Details
dbcrust-0.38.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
dbcrust-0.38.0-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-32 Details
dbcrust-0.38.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
dbcrust-0.38.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 132.8 MB

Release files / dbcrust-0.38.0-cp310-abi3-win_amd64.whl

Download URL dbcrust-0.38.0-cp310-abi3-win_amd64.whl
Size 14.1 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
10d5229207e554b6f7e133ea4dc240ff3b866ca6f0bad67c498a2a030a433e14
BLAKE2b-256 checksum
How to use checksums
3de56639c0c8024a2087efcbff04d53c3a9b367c13ec735c1c74bc9244ebb38f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / dbcrust-0.38.0-cp310-abi3-musllinux_1_2_x86_64.whl

Download URL dbcrust-0.38.0-cp310-abi3-musllinux_1_2_x86_64.whl
Size 18.2 MB
Tags CPython 3.10 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
97c4fd6dae6b87df406b9f0533394fea749f2ee79bf06fa9b2439039dab1aa4f
BLAKE2b-256 checksum
How to use checksums
1f1070757650387491f6e8ee3afb0694a4a848b8d34a51b4b8b4ac5f32644fbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / dbcrust-0.38.0-cp310-abi3-musllinux_1_2_aarch64.whl

Download URL dbcrust-0.38.0-cp310-abi3-musllinux_1_2_aarch64.whl
Size 18.1 MB
Tags CPython 3.10 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
51a948517bc8c9d2c9af87437617cc37cd337aea3ba81afe9315736317543e3c
BLAKE2b-256 checksum
How to use checksums
f6792da40bb2370452aa4217dc220f9460d5e1cf0a7f47f42988657113c69250
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / dbcrust-0.38.0-cp310-abi3-manylinux_2_28_aarch64.whl

Download URL dbcrust-0.38.0-cp310-abi3-manylinux_2_28_aarch64.whl
Size 17.9 MB
Tags CPython 3.10 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
6f2d1a7a995943c3b91b81b52e21950278d05d690a5aa1fec81769211a1db118
BLAKE2b-256 checksum
How to use checksums
dd8b6cee106765c1846368cdfed48a8ec4676c7fea44451d12cc9822482a839e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / dbcrust-0.38.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL dbcrust-0.38.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 17.4 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
4dba69f9a304a07a47394b5df0b764665d020b1c30d6252cd1f74591256bb659
BLAKE2b-256 checksum
How to use checksums
418fd2b228bb6d838c8ef80f94063a13ec5b1e572c3ac5acadec14739be6a836
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / dbcrust-0.38.0-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl

Download URL dbcrust-0.38.0-cp310-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Size 18.2 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-32 abi3
SHA-256 checksum
How to use checksums
f493966c40bc7f7d054244d9b6eb2766b894bed56676d19390b9ac90582d73ab
BLAKE2b-256 checksum
How to use checksums
ed2ef78112358ada400ac6e9f5b0b1fb283ac179477804d907d7466a6814d4bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / dbcrust-0.38.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL dbcrust-0.38.0-cp310-abi3-macosx_11_0_arm64.whl
Size 14.6 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
669bdc4f2f6b30aa3ecd44fdf4901235ab8c0dc045cfd15764a26b5fa83245b5
BLAKE2b-256 checksum
How to use checksums
a69c2c01b042296fb728b7c77877a543be867dd2110907ad424bfd5500023d44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release files / dbcrust-0.38.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL dbcrust-0.38.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 14.3 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
4f5eaeb756788bdd75aef3cc8bc40e1b9239851a7fa56c3add7c48e2718b9a67
BLAKE2b-256 checksum
How to use checksums
0e807894818a6a0033d0e2b636be540114bfcf36b18bee4fe95b8bee5c693f8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.38.0 This release

8 release files

0.37.0

8 release files

0.36.0

8 release files

0.35.0

8 release files

0.32.0

8 release files

0.31.2

8 release files

0.31.1

8 release files

0.31.0

8 release files

0.30.1

8 release files

0.30.0

8 release files

0.29.0

8 release files

0.28.1

8 release files

0.27.1

8 release files

0.27.0

8 release files

0.26.1

8 release files

0.26.0

8 release files

0.25.0

8 release files

0.24.0

8 release files

0.21.0

8 release files

0.20.1

8 release files

0.20.0

8 release files

0.19.0

8 release files

0.18.0

8 release files

0.12.0

7 release files

0.11.5

7 release files

0.11.4

7 release files

0.11.3

7 release files

0.11.2

7 release files

0.11.1

7 release files

0.11.0

7 release files

0.10.5

7 release files

0.10.4

7 release files

0.10.3

7 release files

0.10.2

7 release files

0.10.1

7 release files

0.10.0

7 release files

0.9.0

7 release files

0.8.1

7 release files

0.8.0

7 release files

0.7.4

7 release files

0.7.3

7 release files

0.7.2

7 release files

0.7.1

7 release files

0.7.0

7 release files

0.6.2

7 release files

0.6.1

7 release files

0.6.0

7 release files

0.5.0

7 release files

0.4.1

7 release files

0.4.0

7 release files

0.3.1

7 release files

0.3.0

7 release files

0.2.0

7 release files

0.1.0

7 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page