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

File metadata

File hashes

Hashes for wrap_rocks-0.6.9-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b5f9293108e21ed31929a6ad24ac9145d26766d9139cfd142f8b42a23811d1c9
MD5 7bd56216af857498b0d68b322c5219ed
BLAKE2b-256 c01f940fcbc815e96f46aa55d13c6954c203ff448efbf6cb0f885a6bfe5c8688

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.9-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d659015e72bf4128547768b243f0bf604dbb5ce57989232ce151001a4a6522eb
MD5 d37b0abb34dd81089d765d3fed9a6de2
BLAKE2b-256 36b6af6614c81f2694a55acf6693b9b4991dad1db6bac7ba6624562d030c089f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.9-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 26bc60db67d32904ecb4b988f23cece7c99c2c0ecca1e65651c30aee5b7421c5
MD5 94d0158d74382b1596c9ff3ca184d0fa
BLAKE2b-256 d6286ed7dd60e275ac3633b02f523dcec26291bf4f13b1f93b2e219ea99d9765

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.9-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0406053457c8d5ffc1652352d6b734191d01c37f808c6835493aa3f566671bdd
MD5 fb83a4f903175a642173147ff720015e
BLAKE2b-256 9774013b1a80bd056f9d2aa6b0fabee9334d221da0327b18d1c66f052b1a4c22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.9-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d05d1dee9f64c73e5e6d19a4cc987c8f9099d21d1116dd0fb0919fdc3d8c157b
MD5 ab2df869cc17875d3040b204744aa1cb
BLAKE2b-256 31683d75ef108416c767f4cf10813efe6911a9a10b62b3b239fea6c7ea9331b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for wrap_rocks-0.6.9-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b5268c6de142c6f4f804fdb8f3a2508f1462dc435309cf231580d7954689bc92
MD5 258c41e91bcbbe7893bedab45154e0e3
BLAKE2b-256 19109391482b4ca9c83b90cf28112aa1b0841dd50abde6eb4ecd09bcee8d8d97

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