A clean-room, strictly read-only local SQLite schema and query browser, written in pure C99.
One binary, three modes: discovery metadata, a JSON node API, and a responsive HTML tool UI.
The public-domain SQLite amalgamation (vendor/sqlite3.c, 3.53.4) is compiled into the
binary, so nothing needs a sqlite3 CLI, libsqlite3.so or sqlite3.dll on the node.
| slug | sqlite |
| executable | plugin_sqlite (plugin_sqlite.exe on Windows) |
| metadata | {"name":"sqlite","desc":"SQLite viewer"} |
| category | devtools |
| license | MIT (SQLite itself is public domain) |
.db / .db3 / .sqlite / .sqlite3 files under /workspace, /codebases, $HOME and $SQLITE_ALLOWED_ROOT (depth 4, 60 000 entries per root, symlinked
directories never followed). Each root gets its own budget, so one enormous tree cannot
starve the others, and action=dbs reports per-root dbs / scanned_entries /
truncated so a short list caused by the cap is visible rather than looking like an empty
node. $SQLITE_SCAN_BUDGET lowers the allowance (tests use it).
(unique or not).
SELECT / WITH / read-only PRAGMA / EXPLAIN statements and streams typed rows as JSON: integers and reals as JSON numbers, text as strings, NULL as null, and BLOBs as a
bounded {"blob_bytes":N,"hex":"..."} preview.
Ctrl+Enter to run), sortable result grid, CSV and JSON copy, dark and light themes, ?embed=1 aware.
Two independent mechanisms, because a single one is a promise and two are a design:
sqlite3_open_v2(), plus SQLITE_LIMIT_ATTACHED = 0.SQLITE_OK only for SQLITE_SELECT, SQLITE_READ, SQLITE_RECURSIVE, SQLITE_FUNCTION, and a whitelist of read-only PRAGMAs
(table_info, index_list, foreign_key_list, page_count, integrity_check, ...).
Everything else — INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, ATTACH, DETACH,
TRANSACTION, REINDEX, VACUUM, and settable pragmas such as journal_mode=... — is
SQLITE_DENY, which the engine enforces at prepare time.
On top of that:
select, with, pragma, explain or values (friendlyerrors rather than a bare "not authorized"), and stacked statements are rejected.
truncated: true when the cap bites).sqlite3_progress_handler aborts any statement that runs past ~2 s (aborted: true, partial rows kept).
Only regular files with a database suffix, resolved through realpath(), inside one of the
allowlisted roots are opened. Rejected outright: any .. segment, file:-prefixed SQLite URI
filenames, :// schemes, query strings and fragments, non-database suffixes, symlinks pointing
out of a root, and system paths such as /etc/passwd. An allowlisted-but-absent file answers
not_found, which is a different error from forbidden_path on purpose — the UI can tell "you
looked in the wrong place" from "you are not allowed there".
Test the policy yourself:
curl -s -G 'http://127.0.0.1:8150/plugin_sqlite' -H 'X-Bot-Password: <pwd>' \
--data-urlencode 'action=query' --data-urlencode 'db=/etc/passwd' --data-urlencode 'sql=select 1'
# {"ok":false,"error":"forbidden_path",...}
All routes answer application/json; charset=utf-8 unless noted. Everything except --meta
requires the node password (X-Bot-Password, Authorization: Bearer, or ?pwd=; unset
BOT_PASSWORD disables the check, which is how you run it from a shell).
| Route | Answer |
|---|---|
?action=dbs | {ok, roots:[{label,path,exists,dbs,scanned_entries,truncated}], count, max_scan_entries, dbs:[{path,root,bytes,mtime}]} |
?action=schema&db=<path> | {ok, db, tables:[{name,type,rows,columns:[{name,type,notnull,pk}],indexes:[{name,unique}]}], table_count} |
?action=query&db=<path>&sql=<SELECT ...> | {ok, db, columns:[{name,decl}], rows:[[...]], row_count, truncated, limit, ms, aborted, types} |
?action=info | plugin id, version, bundled SQLite version, platform, limits |
?format=json | falls back to action=dbs |
GET (no action) | HTML explorer, honours ?embed=1 |
query also accepts POST with a sql=... body: the caller is expected to hand the urlencoded
body through the HTTP_BODY_FILE environment variable (the form scorpiox-server uses). A bare
body is treated as the statement itself.
Rows: text is a JSON string, integer/real are JSON numbers, NULL is null, BLOB is
{"blob_bytes":N,"hex":"..."} with the hex preview truncated after 48 bytes.
make # native (glibc) -> ./plugin_sqlite
make musl # static musl x86_64 -> ./plugin_sqlite.musl
make arm64 # static aarch64 -> ./plugin_sqlite.arm64
make win64 # MinGW-w64 static PE -> ./plugin_sqlite.exe
make macos # Apple clang (on macOS) -> ./plugin_sqlite
make test # run tests/run.sh
Windows without a cross toolchain: powershell -ExecutionPolicy Bypass -File build.ps1.
The SQLite amalgamation compiles at -O1 (roughly 10 s on a laptop, about a minute on a Windows
box). Bumping the engine to -O2 changes nothing measurable for an I/O-bound 500-row browser.
tests/run.sh builds a throwaway database, points the plugin at it with SQLITE_ALLOWED_ROOT,
and runs 134 assertions:
--meta shape (single-word name, at most 15-char description, compact, valid JSON)X-Bot-Password / Bearer / ?pwd= accepted, wrongpassword refused, HTML route gated too
including that every allowlisted root is scanned with its own budget (a truncated root is
reported as truncated: true and does not starve the roots after it)
null, BLOB hex previewATTACH/DETACH/REINDEX/VACUUM/BEGIN/settable PRAGMA/stacked statement/WITH-DELETE) plus proof
the file on disk did not change and no ATTACH file appeared
/etc/passwd, .. traversal, file: URIs, :// schemes, non-db suffixesContent-Length, embed behaviour)e_machine, static-link proof, MZ header)
cp plugin_sqlite ~/.scorpiox/plugins/ && chmod +x ~/.scorpiox/plugins/plugin_sqlite
curl -s -H 'X-Bot-Password: <pwd>' 'http://127.0.0.1:8150/plugin_sqlite?action=info'
Discovery is automatic — no server restart. On Windows the plugin directory is
%LOCALAPPDATA%\scorpiox\plugins\.
git clone https://plugingit.scorpiox.net/scorpiox-bot-plugin-sqlite.git
Audit src/plugin_sqlite.c, change the allowlisted roots or the row cap for your setup, and
compile it yourself — it is one C file plus the vendored amalgamation and libc.
src/plugin_sqlite.c the whole plugin (3 modes, path gate, authorizer, HTML UI)
vendor/sqlite3.{c,h} public-domain SQLite 3.53.4 amalgamation
tests/run.sh 134 offline assertions
Makefile native / musl / arm64 / win64 / macos / test / clean
build.ps1 Windows MinGW static build
release-dist.sh build all targets, package, publish, mirror
plugin.json marketplace metadata
1.0.1 — Every allowlisted root now gets its own discovery budget. Previously one global
60000-entry counter let a large tree (/codebases, a monorepo) exhaust the allowance before the
walk reached $HOME, so a database in the home directory was invisible and the panel reported a
single database on a node that had several. action=dbs now reports per-root dbs /
scanned_entries / truncated (plus max_scan_entries), the UI names the roots it walked and
says when a cap was hit, and $SQLITE_SCAN_BUDGET lowers the allowance for tests.
1.0.0 — First release: three modes, SQLite 3.53.4 amalgamation compiled in, read-only
authorizer, path allowlist, 500-row cap, ~2 s statement budget, six build targets.