Keep scans read-only
Existing files are opened with read-only SQLite connections. Each scan runs in one read transaction for a coherent snapshot.
SQLite before / after · Read-only audit
Compare two existing database files without running migration or repair SQL. SQLite Audit Kit captures schema, exact row counts, NULLs, actual storage types, foreign-key violations and the candidate keys you specify, then produces JSON and one offline HTML report.
Existing files are opened with read-only SQLite connections. Each scan runs in one read transaction for a coherent snapshot.
Full scans count rows, NULLs and actual storage classes. Specify intended candidate keys to measure duplicate groups and excess rows.
Use an offline HTML report, structured JSON or an optional regression exit code in automation. Findings include coverage limits.
Keep a real baseline before the application update. With Python 3.10+ and standard sqlite3, clone the repository and scan both existing files with the same rules:
git clone https://github.com/fuxing0910-hue/sqlite-audit-kit.git
cd sqlite-audit-kit
python -m sqlite_audit scan before.db --output before.json --key readings:sample_key
python -m sqlite_audit scan after.db --output after.json --key readings:sample_key
python -m sqlite_audit compare before.json after.json --html report.html --json report.json --fail-on-regression
Replace the database paths and readings:sample_key with your actual inputs and explicitly intended key. Omit --key if you do not want a candidate-key check. Repeat it to check multiple keys; use comma-separated columns for a composite key.
Open report.html in a browser. The report is standalone, with no scripts or external assets. If you already have compatible audit snapshots, go straight to compare.
python -m sqlite_audit demo --output-dir synthetic-demo
The demo writes invented before/after databases and a report into a fresh directory. It reproduces one foreign-key and one selected-key duplicate regression. Demo findings are not evidence about your database.
The optional gate has three outcomes. With --fail-on-regression, exit 0 means no counted regression in comparable checks; 1 means a counted regression; 2 means invalid input or incomplete coverage without a definite regression. Reports include findings and coverage limits. A definite regression takes precedence over incomplete coverage.
An agent with a shell can execute the CLI above. A coding agent that supports Agent Skills can install the bundled workflow into the current project with the optional Skills CLI:
npx skills add fuxing0910-hue/sqlite-audit-kit --skill sqlite-migration-audit
Node.js is required for this installer. The skill includes its Python implementation; its commands require Python 3.10+ with standard sqlite3, without pip or a repository checkout.
A request you can give after installation:
“Compare these before and after SQLite databases read-only. Check whether foreign-key violations or duplicate keys for readings.sample_key increased, and write an offline HTML and JSON report.”
Supply actual baseline and current paths, and specify intended keys. See the skill instructions or CLI, Python and function-tool integration guide. The host application must expose an installed skill or registered tool for model selection.
Scan the existing before and after database files into JSON audit snapshots using identical candidate-key rules. Then compare the snapshots and write an offline HTML or JSON report. The scans open existing files read-only and collect measurements within one read transaction per database.
Foreign-key violations are counted. Candidate-key duplicate checks are opt-in with --key table:column[,column] and exclude rows with any NULL key component. The regression gate detects increased foreign-key counts, increased selected-key duplicate groups or excess rows, and a failed after integrity check; counts do not identify whether the violating records changed.
You can scan the current database and inspect its current findings. A before/after comparison needs a real historical baseline. Scanning the current database twice cannot establish what an earlier update changed.
No. A pass means no counted regression in comparable checks. Existing violations can remain unchanged. Row-count differences, schema changes, more NULLs and mixed storage types are observations, not automatic failures. Counts do not prove application semantics, and unsupported or unfinished checks limit coverage.
Ordinary main tables are audited. Virtual and shadow tables are explicitly unsupported; SQLite 3.37+ is required to classify them. No attached databases or custom extensions are loaded. Full scans can be expensive and can hold locks or delay WAL cleanup.
Reports omit record payloads, BLOB bytes, duplicate-key values and rowids. Schema SQL, default literals, names and SQLite diagnostics remain; review them before sending a report to others or a model API. See the complete measurement and privacy reference.
应用更新完成后,可以用 SQLite Audit Kit 比较真实的更新前、更新后数据库:结构、精确行数、NULL、实际存储类型、外键违规和明确指定的重复键。它生成离线 HTML 和 JSON 报告,不执行迁移或修复。
git clone https://github.com/fuxing0910-hue/sqlite-audit-kit.git
cd sqlite-audit-kit
python -m sqlite_audit scan before.db --output before.json --key readings:sample_key
python -m sqlite_audit scan after.db --output after.json --key readings:sample_key
python -m sqlite_audit compare before.json after.json --html report.html --json report.json --fail-on-regression
替换数据库路径与候选键。两次扫描须使用相同的键规则;不需要检查候选键时省略 --key。扫描通过只读连接、单个读事务完成,HTML 可离线直接打开。
npx skills add fuxing0910-hue/sqlite-audit-kit --skill sqlite-migration-audit
安装器需要 Node.js,运行只需要 Python 3.10+ 与标准库 sqlite3。安装后可描述:“请只读比较这两个更新前后的 SQLite 文件,检查外键违规和 readings.sample_key 重复是否增加,生成 HTML 与 JSON 报告。”
可以扫描当前数据库并说明当前发现,但不能把当前数据库扫描两次,冒充更新前后比较。比较需要真实的历史数据库或兼容审计快照。
通过只表示可比较的检查中没有计数回归;原有违规可能仍然存在,计数相同也不表示违规记录相同。结构、行数、NULL、存储类型变化属于观察结果,不自动导致失败。候选键检查排除任意键列为 NULL 的行,不支持虚拟表或影子表,未完成的检查会限制覆盖范围。
全量扫描较大数据库可能耗时或持有读锁。报告虽不包含记录正文和重复键值,仍含结构 SQL、默认值和诊断元数据,分享前请检查。