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

File metadata

File hashes

Hashes for wrap_rocks-0.6.10-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c7b61bf0dbabb91381aaa924a042339e99804d27c50b2e24278188605ee9e82e
MD5 0c0b83e8a9e8c971d0b707e0931ffcef
BLAKE2b-256 34ccc21d01602d4fb97cc7f497da9f00244953fbd320316fe3793561cfd011ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.10-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9b7c58c37795d3cb4850cb7c02fd8e094d33c3d747d768ef18ae23220ed00d15
MD5 b7dba57eb2b9dae5285941ff57d69ba2
BLAKE2b-256 7bfec16edb427e72f3cfa0f408abbc10221d07dd3712cfe1cd8cddc04f7e4381

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.10-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0d08b43c79da9afa93eef5102ecda173ce323faafe4783ac690e9f61ad958e7f
MD5 fe03de0859ea2fcffd7bd719918e7d05
BLAKE2b-256 3cfa79f318f57b29a6962d47d295bef2c3e4a1b41531acb3ee7e2d4fa073b39c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.10-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2dae3ffe2dbf248217d580f4170bc03b8e11df151a0285d643817feb74c9763a
MD5 d00599863028d59778998f595c8071e8
BLAKE2b-256 6e03c8c6df51f01a705aad351de3858d19d3a6fa34b88a6fed9ec8c38cfa6170

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.10-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f70e97441949365cd3f56224519c4eed5e25d8ff09b5e3076e14d35c83777f24
MD5 c7c1db8f74b71ab861474992d86ab9e8
BLAKE2b-256 4abaa861c2201ada014247da073598e7ee3dbdfd97c76ab54a29d1d96d213441

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.10-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 72a7502b8561e09b840abd8ede3254c0097ed8ca59c4ab0416995ae8cf776299
MD5 97f6c8a6dfda2b28f5386a7900961294
BLAKE2b-256 c27e8534132fb2022490a0d79634d227c80a33fa7754f89b727a00b3961cb094

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