Skip to main content

sqlite-bytes-store

sqlite-bytes-store is a small, typed, dependency-free MutableMapping for bytes keys and bytes values, backed by SQLite.

It is meant for write-heavy byte stores where a plain dict is too temporary, shelve is the wrong shape, and the stdlib dbm.sqlite3 backend spends too much time committing individual updates.

Install

python -m pip install sqlite-bytes-store
uv add sqlite-bytes-store

Usage

from sqlite_bytes_store import SQLiteBytesStore

with SQLiteBytesStore("cache.sqlite") as store:
    store[b"alpha"] = b"payload"
    store[b"beta"] = b"another payload"

    assert store[b"alpha"] == b"payload"
    assert store.get(b"missing", b"default") == b"default"
    assert b"beta" in store

    store.commit()

The store implements collections.abc.MutableMapping[bytes, bytes], so the usual mapping operations work: len(store), iteration over keys, get, assignment, deletion, clear, and membership checks.

Useful options:

SQLiteBytesStore(
    "positions.sqlite",
    reset=False,              # remove an existing database before opening
    table_name="items",       # validated SQLite identifier
    commit_interval=10_000,   # writes between automatic commits
)

close() commits pending writes and closes the connection. sync() is an alias for commit() for compatibility with other mapping-store APIs.

Why It Is Fast

The table is deliberately simple:

  • key BLOB PRIMARY KEY
  • value BLOB NOT NULL
  • WITHOUT ROWID
  • WAL journal mode
  • synchronous=NORMAL
  • batched commits

That makes it a focused persistence layer for byte-to-byte data, not a general SQLite abstraction.

Benchmark

The repository includes a reproducible benchmark:

uv run --python 3.14 python benchmarks/benchmark_stores.py --items 2000 --repeats 3

dbm.sqlite3 was added in Python 3.13; the package itself only requires Python 3.10 or newer.

Results from this machine:

  • Date: 2026-06-02
  • Python: CPython 3.14.2
  • SQLite: 3.50.4
  • Platform: Linux 5.15.161btrfs, Intel Core i5-7200U CPU @ 2.50GHz
  • Workload: 2,000 pre-generated 16-byte keys, 128-byte values, 3 fresh databases
  • Metric: median time; speedup is relative to dbm.sqlite3 total time
Implementation Insert median Read median Total median Speedup Disk
SQLiteBytesStore 0.0306s 0.0205s 0.0537s 92.73x 352.0 KiB
dbm.sqlite3 4.9745s 0.0103s 4.9844s 1.00x 372.0 KiB

The read-only path is in the same ballpark here; the big win is the write-heavy path where SQLiteBytesStore batches commits.

Development

uv sync --group dev --extra docs
uv run ruff format .
uv run ruff check .
uv run python -m pytest
uv build --clear
uv run twine check dist/*

License

sqlite-bytes-store is distributed under the GPL-3.0-or-later license.

Metadata

Release files for sqlite-bytes-store 0.1.0

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

Source distribution (sdist)

Source distribution for sqlite-bytes-store 0.1.0
File Size Uploaded Provenance Actions
sqlite_bytes_store-0.1.0.tar.gz 21.0 kB Without provenance Details for sqlite_bytes_store-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sqlite-bytes-store 0.1.0
File Interpreter ABI Platform Actions
sqlite_bytes_store-0.1.0-py3-none-any.whl Python 3 none any Details for sqlite_bytes_store-0.1.0-py3-none-any.whl

Total release size: 39.3 kB

Release files / sqlite_bytes_store-0.1.0.tar.gz

Download URL sqlite_bytes_store-0.1.0.tar.gz
Size 21.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9342b1724356e6f01e60a92454e3899aa869dbe848e146dec03d1b514cd8daea
BLAKE2b-256 checksum
How to use checksums
997ec50c4b3db12b71fba2cd323e66413bb268ed6c85d1199fcbf4dd914ed74f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.23.4","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / sqlite_bytes_store-0.1.0-py3-none-any.whl

Download URL sqlite_bytes_store-0.1.0-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d974f0064f91e1b258e3e683fbde747c0a2a92f15ad6af05cac71f02a48244e
BLAKE2b-256 checksum
How to use checksums
01fd84fabaa33c47d3d75415b97d4e6b7910775d6194f5032ce15b7138d316da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.23.4","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for sqlite-bytes-store 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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