Skip to main content

No project description provided

Project description

wrap-rocks

Minimal Python bindings for RocksDB
Built with PyO3, powered by RocksDB, and packaged via maturin.

🚀 Features

  • Fast key-value store backed by RocksDB.
  • Pythonic API with support for both strings and bytes.
  • Optional compression: zstd (default) or snappy.
  • Toggleable WAL (Write-Ahead Log) behavior.
  • Lightweight, no-dependency interface for read/write/delete operations.
  • Wheels for Python 3.8–3.13 (manylinux-compatible).

📦 Installation

pip install wrap-rocks

Or, from source (requires Rust and maturin):

maturin develop

🐳 Building with Docker

You can build wheels locally using the provided Dockerfile, or use the prebuilt image on Docker Hub. The container should support every python version from 3.8 to 3.13.

Option 1: Build your own image

sudo docker build -t wrap-rocks -f docker/Dockerfile .
sudo docker run --rm -v $(pwd):/io wrap-rocks python3.13 -m maturin -i python3.13 build --release

Option 2: Use the prebuilt image

sudo docker pull saferq/wrap-rocks:local
sudo docker run --rm -v $(pwd):/io saferq/wrap-rocks:local python3.13 -m maturin -i python3.13 build --release

🧪 Example

from wrap_rocks import RocksDB

# Open or create the database
db = RocksDB("mydb", compression="snappy")

# Store string data
db.put("seq1", "AGCT")
print(db.get("seq1"))  # "AGCT"

# Store binary data
db.put_bytes("meta", b"\x00\x01")
print(db.get_bytes("meta"))  # b"\x00\x01"

# Remove a key
db.delete("seq1")

# Flush and compact
db.flush()

⚖️ API Overview

RocksDB(path: str, compression: Optional[str] = None)

  • Initializes a RocksDB database at the given path.
  • Creates directories automatically if missing.
  • Compression options:
    • "snappy": fast, lightweight
    • Default is "zstd": higher compression ratio

put(key: str, value: str)

Stores a string value under a string key.

get(key: str) -> Optional[str]

Retrieves a string value by key. Returns None if missing.


put_bytes(key: str, value: bytes)

Stores arbitrary binary data under a string key.

get_bytes(key: str) -> Optional[bytes]

Retrieves binary data as bytes. Returns None if missing.


delete(key: str) -> bool

Removes a key (and its value). Returns True on success.


flush() -> bool

Flushes in-memory writes to disk and triggers compaction.

Use this before backups or to minimize storage bloat after bulk writes.


enable_wal() and disable_wal()

Toggles Write-Ahead Logging. By default, WAL is enabled for durability.

Disabling WAL can improve write performance or help avoid data duplication after breaking changes in schema or logic. Use with care—data may be lost on crash.


⚙️ License

Licensed under the Apache License, Version 2.0 (LICENSE).


🔮 Why wrap RocksDB?

This crate was built to expose a minimal and predictable interface to RocksDB for Python projects—particularly for use cases like:

  • Storing FASTA-style header:sequence pairs.
  • Staging byte-encoded ML or bioinformatics data.
  • Quickly dumping + retrieving structured data with compression.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

wrap_rocks-0.6.8-cp313-cp313-manylinux_2_28_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

wrap_rocks-0.6.8-cp312-cp312-manylinux_2_28_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

wrap_rocks-0.6.8-cp311-cp311-manylinux_2_28_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

wrap_rocks-0.6.8-cp310-cp310-manylinux_2_28_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

wrap_rocks-0.6.8-cp39-cp39-manylinux_2_28_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

wrap_rocks-0.6.8-cp38-cp38-manylinux_2_28_x86_64.whl (4.2 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

File details

Details for the file wrap_rocks-0.6.8-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for wrap_rocks-0.6.8-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1b2de1ad2bd322259f6cdc424778d3ea60235c2f20aebe7e00850acbad19c098
MD5 36440eb4858a8c0fb4394ff307225fde
BLAKE2b-256 fede667100a7e3ea5776a988bfefc08fa2e26919c1f41499babf55467d9c1540

See more details on using hashes here.

File details

Details for the file wrap_rocks-0.6.8-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for wrap_rocks-0.6.8-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a16173974972c8204fb071fcd8a9d06659b61965d56a85c3486acc994c21de8d
MD5 8209653968daeb9ef6389acdd6d5b1af
BLAKE2b-256 7b3d874584d1967b001bf2b7630d5c76d1cad7aefa59f96a6563ce8bfeace75f

See more details on using hashes here.

File details

Details for the file wrap_rocks-0.6.8-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for wrap_rocks-0.6.8-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5d071fce3f55acff8d5ac7fcb2308159507e428f463f15388cb53e4db035f45d
MD5 599e6926d62efc7b937671a4a4409132
BLAKE2b-256 8e506376a197adb85fa8afe7cf1d069dd4101e8f04fa2c37df4c99bd9647d433

See more details on using hashes here.

File details

Details for the file wrap_rocks-0.6.8-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for wrap_rocks-0.6.8-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1d5ed288730992f2ade7eab3d4898b803efa340bb48394d50e3f933623c18d6d
MD5 837ebde0692956a94a4b41352f9eadad
BLAKE2b-256 3fd11d4b2ce784ff437701bca246f77fc25407354c28e7605d7d24307fa868f2

See more details on using hashes here.

File details

Details for the file wrap_rocks-0.6.8-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for wrap_rocks-0.6.8-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 298eb87e399206537c2c9437ca4677a23e0f30af569f2e16ff1c46375f680169
MD5 3c0b4aaf2fe6be819c696b6676f6307b
BLAKE2b-256 0e9e725bdf105a8a998d8ecda70a9ba37c1df453a9b9330ec82f421ed8984a09

See more details on using hashes here.

File details

Details for the file wrap_rocks-0.6.8-cp38-cp38-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for wrap_rocks-0.6.8-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 edc9112f7267c90cbe6a5fa3509084ffefb13044172c1f437639d36e7123125c
MD5 bedbe51c530a4717a485d993c725cd08
BLAKE2b-256 e0067264192d9d7dfb4e020ea14563296dbb3f83d042aebed3b2011f04ea1229

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page