Problems it solves
- "Is this SQLite file healthy?" —
inspect_format()reads the file header and page structure without opening a connection or modifying anything, so you can safely triage a suspect database before touching it. - "Did something silently corrupt my database?" — the managed connection tracks
is_healthy, wraps writes in explicit transactions, and surfaces uncertain outcomes (I/O errors, failed commits) rather than swallowing them. - "My app crashed mid-write — what state is the database in?" — the optional transaction journal records every managed write before SQLite executes it, so committed transactions can be replayed onto a restored backup candidate.
- "I need a verified backup I can trust." —
create_recovery_point()takes an online backup via SQLite's native API, verifies it withquick_checkorintegrity_check, and publishes a signed JSON manifest only after it passes. - "I want to test fault tolerance without risking real data." —
run_fault_scenario()copies your database into an isolated evidence workspace, injects a deterministic truncation, corruption, or interruption, then captures diagnosis and hashes — your original is never touched. - "How do I reproduce a storage failure reliably?" — every fault scenario is seeded and deterministic;
run_recovery_certification()runs multiple scenarios and exports an aggregate report with stable scenario identities. - "I need to measure how fast my database callback actually is." — the
Benchmarkrunner measures a caller-supplied Python function, tracks per-iteration latencies, and computes p50/p95/p99 and throughput without generating any SQL itself. - "I want to compare results across runs." —
ReportHistoryandcompare_reports()store and diff report snapshots;BenchmarkHistoryandcompare_benchmarks()do the same for benchmark results, with regression detection built in. - "How do I generate realistic workloads for my test harness?" —
TransactionGeneratorproduces configurable, seeded operation and transaction descriptions (uniform, sequential, hot, or Zipfian key distributions) that your harness can replay however it likes.
What Storq does
- Inspect SQLite files: read basic format and header information without changing the file.
- Experiment with the Storq format: create and inspect an experimental
Storq-format file, then use
RecordManagerto perform basic record operations. - Prepare workloads: generate transaction and operation descriptions for a test harness. Workload generation does not execute SQL or modify a database.
- Organize and measure results: build and export reports, compare and keep report history, and benchmark a Python callback supplied by your application.
The Python API intentionally exposes only part of the underlying C++ project. Advanced page/WAL analysis, fault injection, crash simulation, recovery verification, and forensics are not currently available through the Python SDK. See current limitations for details.
How it works
Install the storq distribution and import it as storq. Supported wheels
include the compiled storq._native extension, which connects the Python API
to the native C++ implementation. SQLite format inspection uses that native
code to read and report supported format metadata. Other helpers run in
Python: for example, the workload generator describes operations, while the
benchmark runner invokes the callback you provide and records its results.
Storq-format files are separate from SQLite files. Their create and record APIs are experimental and do not provide full transaction rollback or production database guarantees. Use disposable files and keep verified backups for experiments.
Install
python -m pip install storq
Quick start: inspect a SQLite file
import storq
result = storq.inspect_format("sample.sqlite")
print("Format:", result.format)
print("Page size/count:", result.page_size, result.page_count)
print("Header/structure valid:", result.header_valid, result.structure_valid)
This reports basic format observations; it does not validate every SQL record or index, repair the database, or guarantee that the file is logically consistent.
Create and use an experimental Storq file
import storq
path = "example.storq"
storq.create_storq_database(path, 4096)
records = storq.RecordManager(path)
records.open()
try:
record_id = records.insert({"name": "Storq", "active": True})
print(records.read(record_id))
finally:
records.close()
Only use disposable files for experiments. These record operations are not a replacement for a production database, and Storq does not currently rebuild corrupted data.
Requirements and native extension
Prebuilt wheels are available for supported CPython 3.10–3.14 environments on Linux, Windows, and macOS. Most native APIs require the compiled extension. You can check that it is installed with:
import storq
import storq._native
print(storq._native.__file__)
The extension path should end with a platform extension such as .pyd or
.so.
Learn more
- Project purpose and capabilities
- Python API reference
- Workflows and testing
- Reporting and benchmarking
- Safety and limitations
- Runnable Python examples
Source code, releases, and issue tracking: https://github.com/kingmon6996/Storq
