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.7-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.7-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.7-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.7-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.7-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.7-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.7-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for wrap_rocks-0.6.7-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d5b4a3ef44ab5c968460786b85d26f804f1211635ba77ee3ba42db47b16e7ca0
MD5 0fbbc4b18cb6c8bd19801426ef7a5c3f
BLAKE2b-256 a4ae6326179e1d1a401e8044bba553914951695247a9809da10f27b9c1961ed7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.7-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fe582f3379f7415589f7e4e8b0be528fd830ede7d93867de326907a1594cc3c1
MD5 14555b8121870fad90bb15243a7f8ef9
BLAKE2b-256 a104bc6214ab384fda4a761e8988ba7bd4a531504c0809c8877b5305b127b033

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.7-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 851a4ef4d21d5ebd09a818f4e03219bd1cf3fbbf49c8a3b8641db4d01b765597
MD5 e785b7f665cd9a76fb1e991cf272bbc2
BLAKE2b-256 b72df31e8637f35b4d0713bf89bb2d23054aca243ea3b7d4648079e7fbacf170

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.7-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0ab60523b4ab64e0ffa28a5b3fd6f1afc9b4fe5c4ce1656d43021b5eaf36e5f2
MD5 619188cad2b7df679d2923ccd44e0d78
BLAKE2b-256 d327a179f1c2e4b33588ae7bcb577874c43dd27afd8c1a5402cc6f7b60732184

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.7-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7c9e74ee73659b72e49e965748f5bba3ff770794d8f265ebaf2fc32fe4881084
MD5 a5b955b9b4361d2fcb57ad3f62a38aa2
BLAKE2b-256 fd5cf0795142df16c8e5a33ec73656a62e55652c0474ba2b3d37e66e38e68c81

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.7-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 18220de232446a34f336bac3e5665bf0c8ef8b3f467ec25305fce94a484126f9
MD5 624984a1445350fe979bfa2295f8f93c
BLAKE2b-256 cd307a6e89e792012f5ef5a96754f36e210cc01e152e7f1ed2829855a2261a56

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