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
sudo docker run --rm -v $(pwd):/io saferq/wrap-rocks 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.0-cp313-cp313-manylinux_2_28_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

wrap_rocks-0.6.0-cp312-cp312-manylinux_2_28_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

wrap_rocks-0.6.0-cp311-cp311-manylinux_2_28_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

wrap_rocks-0.6.0-cp310-cp310-manylinux_2_28_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

wrap_rocks-0.6.0-cp39-cp39-manylinux_2_28_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

wrap_rocks-0.6.0-cp38-cp38-manylinux_2_28_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.28+ x86-64

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7bc5143e3085c55d1c371ce97ade7632f1d85b5da72828ac211acece32b02374
MD5 e6d7ee506221a2f65742c5b6f0d1a536
BLAKE2b-256 e9c044bd066fe01e22e14a8d47530071dd100efe9ed2da64dd40f7599e463d07

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f10b123ce33dd88371649ecfe89aad05c4be6e25b82d0811859bd9b4def00d82
MD5 aabad41122ba17f8ef09043de4613103
BLAKE2b-256 e4ae61c2cc91a064447b68c0dc28c98590fc19f3d68efef37c4ab820daae7859

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c0402b5abf488661a7154a810b1bc0f4d1cdd9aa11319c53e2b8478b85d175f2
MD5 3609ec7ac0ae3d04242649100a01a5fc
BLAKE2b-256 ffc92bca30be5bd09e44151920d859738413040353a48ca5c6773539e83f9a80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 700672bb0e35a79fabaf5922b1b2a8534db9039ef4bbf330ace5a3336b8f807d
MD5 51aa1b2bc8dc3fb25cadbd6e3f282afe
BLAKE2b-256 55cdd634bc5ccddb474fcd59742a4736f5d0aa3886d8a9964dede273b924d082

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 76cbf9fa1e949546d76edc6d85f52a87c9c49a49a57256b6ae68227f1d2e99c6
MD5 262dbdd03945866a7cf12976239de540
BLAKE2b-256 bbd32466572f9635e7c35e84f608739b8508f7e7862eff4542d39640cdad8d79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.0-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 156dfdca6ba8e222a2cbe7aa1bb01b7d83a483beaebbfc2f2049d24247c147a9
MD5 002b9bef26038c1d394df718029cd7f9
BLAKE2b-256 1634ad4a32b33fe05380d4bcd478f33ceeef80e60e878bde97b8dba2c43d103f

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