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

File metadata

File hashes

Hashes for wrap_rocks-0.6.6-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3ba01e474b043e4b75256897b6107fb755800d644300fa02ad003cd031c74348
MD5 3737bd792a7aeb3e90084395c73f938b
BLAKE2b-256 312e31c79451deba21300a6efef6eacfb63b4c1b58513570a585dba5efd95c7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.6-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bcaaa4b1f9621344d1a6f74278faab358b8c03c9e0220cb66f5bef4b95b27190
MD5 4a9dc84bb097346ffa30844f21371989
BLAKE2b-256 d043c580500c18189aa1adecb1c0c8fbefeb3de7ec485dbf4a9cf06e4a9b0358

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.6-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7447b48b91f4a59731b5ac90f43d92f52941796a6e23bb10640de95f2987b03d
MD5 4d6d3a4ef4cf58da0dcf5b11da109724
BLAKE2b-256 88f4ddd9946f61ace6504ffdcd70f62dcec4e03df659a8e2ba070d13842189a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.6-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9b2f248154133f0fdad7eef220691a9e1aba4a32c6195f79d4e82fa6c4b63800
MD5 7607170dcaf7593107f95f8a76c90179
BLAKE2b-256 ce921918ae0e919f75e28d26cf6473809726eb947419a83116dd8c854e21d4f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.6-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d22ce09514ca7295892e61b233b41f547df14e07318f9b2c829c22f360f739a8
MD5 d44c091a6e8a5c8714bf3f2fda75d223
BLAKE2b-256 3c09f6fdb6c178036a1f6aec264d1a44e57a01bd80d76225fc2aaf1e05125ecf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.6-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 990b21fc9159f9694649a92978b023c8694a23a610cffa2a97dfb2dd56623022
MD5 8e087f2c09ea96b24374f31c31856eb4
BLAKE2b-256 7c5e9ae5ec110a8e13a64e6a5dea9c0d47d91f6687efafaa2a751c4021cfde40

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