A zero-config SQLite database inspector CLI. When you're handed an unknown .db file — a SaaS backup, old app data, a bundled fixture — the first thing you want is "what's in here?". sqlite-stats answers that in one command: tables, row counts, columns, indexes, foreign keys, file size, and EXPLAIN QUERY PLAN rendered as a tree.
Everything is done with standard SQLite PRAGMA calls. The binary is a static Alpine musl build with rusqlite's bundled feature, so there are no runtime dependencies on a system libsqlite3.
sqlite-stats mydata.db # human-friendly summary
sqlite-stats mydata.db --format json # machine-readable
sqlite-stats mydata.db --format markdown > report.md # good for PR comments
sqlite-stats mydata.db --verbose # + per-column type / nullability / default
sqlite-stats mydata.db --tables users,orders # limit to a subset
sqlite-stats mydata.db --explain-query 'SELECT * FROM posts WHERE user_id = ?'Sections in the default human report:
- Database — file size, page size, page count, encoding, journal mode,
user_version - Tables — one line per user table:
name / rows / cols / indexes / approx bytes - Views — name list
- Indexes — name, table, columns, unique / partial flags
- Foreign keys — resolved pointers
- Top 5 largest tables — by
dbstatpayload bytes where available, otherwise a row-count estimate
| Flag | Default | Description |
|---|---|---|
--format human|json|markdown |
human |
Output format |
--verbose / -v |
off | Include per-column info |
--tables NAME,NAME |
all | Limit to specific tables |
--no-views |
off | Exclude views |
--no-system |
on | Exclude sqlite_% tables |
--explain-query 'SQL' |
- | Wrap EXPLAIN QUERY PLAN and render as a tree |
Exit codes: 0 success, 1 can't open DB or bad query, 2 bad args.
cargo build --release
./target/release/sqlite-stats ./mydata.dbdocker build -t sqlite-stats .
docker run --rm -v "$PWD":/work sqlite-stats /work/mydata.dbThe final image is a non-root Alpine runtime with just the static binary.
cargo testAll tests use :memory: databases.
SQLite's PRAGMA interface is fantastic but impossible to remember. PRAGMA page_count, PRAGMA table_info(x), PRAGMA index_list(x), PRAGMA index_info(idx), PRAGMA foreign_key_list(x), the dbstat virtual table, EXPLAIN QUERY PLAN — each of these is one line of Rust through rusqlite, and walking them gives you a surprisingly complete picture of a database. This CLI is just a nice way to run all of them at once.
MIT.