LevelDB reader for Python — Rust core with PyO3 bindings
Project description
rleveldb
A LevelDB reader for Python, implemented in Rust. Reads .ldb (SSTable), .log (write-ahead log), and .sst files without linking against the original C++ LevelDB library. Snappy decompression is handled internally.
The Python API follows the same shape as ccl_leveldb, so it can act as a drop-in for read workloads. The main difference is performance: parsing is done in Rust with memory-mapped I/O, and the GIL is not held during file reads.
Read-only. This library cannot write to or modify databases.
Installation
Pre-built wheels are published to PyPI for Linux (x86-64, ARM64), macOS (x86-64, ARM64), and Windows (x86-64):
pip install rleveldb
To build from source you need a Rust toolchain and maturin:
pip install maturin
maturin develop
Usage
import rleveldb
with rleveldb.RawLevelDb("/path/to/leveldb") as db:
records = db.iterate_records_raw()
# Sort by sequence number to replay writes in order
records.sort(key=lambda r: r.seq)
state = {}
for rec in records:
key = rec.user_key.decode("utf-8", errors="replace")
if rec.state == rleveldb.KeyState.Live:
state[key] = rec.value
elif rec.state == rleveldb.KeyState.Deleted:
state.pop(key, None)
iterate_records_raw() returns every record from every data file, including tombstones. It does not deduplicate or merge—that is left to the caller, which is intentional for forensic use cases where you want to see deleted entries.
Iterating in reverse file order
records = db.iterate_records_raw(reverse=True)
Records come back in descending file-number order. Useful when you only care about the most recent version of each key and want to stop early.
API
RawLevelDb(path: str)
Opens a LevelDB directory. Raises ValueError if path is not a directory or the database cannot be opened.
Supports use as a context manager. Calling .close() or exiting the with block releases file handles and memory maps.
Methods
iterate_records_raw(*, reverse: bool = False) -> list[Record]
Returns all records from all data files, ordered by file number. Each file's records are in the order they appear on disk.
Properties
in_dir_path: str— the path passed to the constructor.
Record
Represents one entry from a data file. All byte fields are returned as bytes objects.
| Attribute | Type | Description |
|---|---|---|
key |
bytes |
The internal key. For .ldb files this includes an 8-byte suffix (sequence number + type byte). |
user_key |
bytes |
The key with the internal suffix stripped. Use this for application-level lookups. For .log files user_key == key. |
value |
bytes |
The raw value. Empty for deleted entries. |
seq |
int |
LevelDB sequence number. Higher means more recent. |
state |
KeyState |
Live, Deleted, or Unknown. |
file_type |
FileType |
Ldb or Log. |
origin_file |
str |
Path to the file this record came from. |
offset |
int |
Byte offset within the origin file. |
was_compressed |
bool |
Whether the block holding this record was Snappy-compressed. |
KeyState
KeyState.Live — the key exists and has a value.
KeyState.Deleted — the key was deleted (tombstone record). value will be empty.
KeyState.Unknown — the state byte could not be determined.
FileType
FileType.Ldb — record came from an SSTable (.ldb or .sst).
FileType.Log — record came from a write-ahead log (.log).
Notes
The key / user_key distinction matters for .ldb files.
LevelDB appends an 8-byte internal key suffix to every key in SSTable blocks. The last byte of that suffix is the type byte (1 = live, 0 = deleted) and the preceding 7 bytes encode the sequence number. user_key strips this suffix, matching what application code originally wrote. For .log files there is no suffix.
MANIFEST files are parsed but not required.
If a valid MANIFEST-XXXXXX file exists in the database directory, rleveldb reads the file-to-level mapping from it. This information is not exposed in the current Python API but is used internally. If no manifest is found, the library still reads all data files it can find.
Corrupt or unreadable files are silently skipped.
Files that fail to open or have invalid magic numbers are skipped rather than raising an exception. This matches the forensic use case where partial databases (e.g., from a disk image) should yield as much data as possible.
File discovery uses the standard naming convention.
Only files with a 6-digit hexadecimal stem and a .ldb, .sst, or .log extension are loaded as data files. Files with other names are ignored.
Building
git clone https://github.com/DedInc/rleveldb
cd rleveldb
pip install maturin
maturin develop --release
For a release wheel:
maturin build --release
Maturin handles the compilation and packaging. The only external build-time dependency is a Rust toolchain (1.70+).
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rleveldb-1.0.0.tar.gz.
File metadata
- Download URL: rleveldb-1.0.0.tar.gz
- Upload date:
- Size: 18.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f40faf88d0e90b878f4cd38988dabc1c7ad8b5b41a1d210d531006f9acf6d267
|
|
| MD5 |
ea70cf41b12b3492a2724ebb2b4031ca
|
|
| BLAKE2b-256 |
c4168f071aea63004b93bcfadbcccd05fb116a48545504e67b82931b24a9ba21
|
File details
Details for the file rleveldb-1.0.0-cp38-abi3-win_arm64.whl.
File metadata
- Download URL: rleveldb-1.0.0-cp38-abi3-win_arm64.whl
- Upload date:
- Size: 192.6 kB
- Tags: CPython 3.8+, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c32caa406b07450abc70fbfba1eb1c866312749a227c3ba1d6eb67fcccd57da5
|
|
| MD5 |
0b8a920edeb22728fbc5f484c66c17eb
|
|
| BLAKE2b-256 |
abec1c917dee76037e52919b504c5675a1d2217885ed5136f2e4ed280d1347bc
|
File details
Details for the file rleveldb-1.0.0-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: rleveldb-1.0.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 196.7 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2763811a5503175efeb701a9e39a739275263ace662cfd6960715d77b64b8b0
|
|
| MD5 |
ef6c72803960b112681dcbca7acde4c1
|
|
| BLAKE2b-256 |
cfd95f448706ef371181a543b8ee1b6a6e21a418e5673e6e1d670e25e46119c6
|
File details
Details for the file rleveldb-1.0.0-cp38-abi3-win32.whl.
File metadata
- Download URL: rleveldb-1.0.0-cp38-abi3-win32.whl
- Upload date:
- Size: 191.9 kB
- Tags: CPython 3.8+, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
579007e4fb32f8a2d49e3f5ad6eabeba9684e53577417b924d1ce4946edad363
|
|
| MD5 |
fa47b8bb9af6d0bd8e3f6a1a48618495
|
|
| BLAKE2b-256 |
55d9f28e8a5e8539d7ed84c0893dd88b3741821341dd4ed020ea57ac2797c778
|
File details
Details for the file rleveldb-1.0.0-cp38-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: rleveldb-1.0.0-cp38-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 543.2 kB
- Tags: CPython 3.8+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d13706a7088d26a64ea30ebf7bdac390b6285200155b91460adee72c833312b9
|
|
| MD5 |
cdcb6a47a5b43ab3ff58862b6a27689b
|
|
| BLAKE2b-256 |
1da8c7917c90e2b851e5037d2b8a98f80ffa25b4b089f1c152cd2ab041a7cd8c
|
File details
Details for the file rleveldb-1.0.0-cp38-abi3-musllinux_1_2_i686.whl.
File metadata
- Download URL: rleveldb-1.0.0-cp38-abi3-musllinux_1_2_i686.whl
- Upload date:
- Size: 581.0 kB
- Tags: CPython 3.8+, musllinux: musl 1.2+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a22a145394ddd94ca66b16f97a1514b54f87dbc82a017031824ff8845ea7af7
|
|
| MD5 |
54a0bfc8e42f3ec0990ae194180a5f22
|
|
| BLAKE2b-256 |
24729924d686796456c0ef8e7b2f079a790be63c230af48e400bd5c68d33447f
|
File details
Details for the file rleveldb-1.0.0-cp38-abi3-musllinux_1_2_armv7l.whl.
File metadata
- Download URL: rleveldb-1.0.0-cp38-abi3-musllinux_1_2_armv7l.whl
- Upload date:
- Size: 618.3 kB
- Tags: CPython 3.8+, musllinux: musl 1.2+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
acc36677e0d1362c4daac1c87752012236f11f189b8fecc416ffa0f4a3f3ad10
|
|
| MD5 |
754a1eb7eb74ec3c70a27e9dcdbee4fa
|
|
| BLAKE2b-256 |
62d6ab9a7b1eefe57045c18e4a0478445f25b65f6d8df3341017ddbcec7ad155
|
File details
Details for the file rleveldb-1.0.0-cp38-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: rleveldb-1.0.0-cp38-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 509.2 kB
- Tags: CPython 3.8+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6dcca59bbe6ae74fbcd84b13a738acb367d1db5d84da79398f711d026b02c91
|
|
| MD5 |
afa9072a6d836e56b4ae11008aa642ea
|
|
| BLAKE2b-256 |
4c079caf41fbc1656cc98b802d7d8625d44950cb9a30c82703b39808e7f8a0ad
|
File details
Details for the file rleveldb-1.0.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rleveldb-1.0.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 337.8 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3ccd6d37b899a2f61caa6b8898a6ac68ce864fb86d6196af820289e42f81490
|
|
| MD5 |
420981d567cb7302abc0e3730460d26b
|
|
| BLAKE2b-256 |
4ba00eba7f6beb0d62704cd712e6d204213bfbdc1a2d694dff930b923dde90cf
|
File details
Details for the file rleveldb-1.0.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.
File metadata
- Download URL: rleveldb-1.0.0-cp38-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
- Upload date:
- Size: 357.9 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ s390x
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cd68bc19df2b4550a14fca6cb32d96cba5605ecfb79c6c9dc679a0d42e159e8
|
|
| MD5 |
7bfa9846e12de8bcecd111973c9a9622
|
|
| BLAKE2b-256 |
2ec2904dd5b4da378cb0ce637df0cf6d87a5ee03076b6f1dda0f70f8276c12f6
|
File details
Details for the file rleveldb-1.0.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.
File metadata
- Download URL: rleveldb-1.0.0-cp38-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
- Upload date:
- Size: 459.2 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ppc64le
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2140ca373d5eda32fa39339fff9933d39d1630473af95dae92ca6b9fe48d1bbd
|
|
| MD5 |
4d5f543b629d23f80fd0437346cd75d6
|
|
| BLAKE2b-256 |
06da542a06a978d1c98fd476850fab436140be4e978d8dbb1aa961f0cefe9eaf
|
File details
Details for the file rleveldb-1.0.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.
File metadata
- Download URL: rleveldb-1.0.0-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
- Upload date:
- Size: 343.0 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARMv7l
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2370542b0bf68672ea5088543a9472802d6cd71bca40dd6b2e2d0dc9e5729b8
|
|
| MD5 |
cff568e6d4f1c268a34acdb6f18430bc
|
|
| BLAKE2b-256 |
9bd76897125e98346d1a8d1ae04d333a2d233acf27e307b3cca21294f66361a9
|
File details
Details for the file rleveldb-1.0.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: rleveldb-1.0.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 333.1 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa836247a019e9120976d69c4f07beb31f16586ab8d2fcd1aae3b9cfc1a4f3f6
|
|
| MD5 |
b56b068a338bdc2173227a961159e6d8
|
|
| BLAKE2b-256 |
ca9901a860a85218e6899ed322c8a151951ebd0a09111e5528b61086351cf478
|
File details
Details for the file rleveldb-1.0.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl.
File metadata
- Download URL: rleveldb-1.0.0-cp38-abi3-manylinux_2_5_i686.manylinux1_i686.whl
- Upload date:
- Size: 365.6 kB
- Tags: CPython 3.8+, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4a8945468ef120d983d51aaa0e6a05d125b301ac7302e1305fec7dd9136eec4
|
|
| MD5 |
e43b53b545b2e49d684ab646c9a0a0cf
|
|
| BLAKE2b-256 |
6b396443a8d3cd30f63343824ebab4f0a0dec5ef8e6f077f32e4e45739bb47bb
|
File details
Details for the file rleveldb-1.0.0-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: rleveldb-1.0.0-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 299.1 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f43ecfe36859f792443a628440f696bbce668a3f78889ea313ca35b3858d71dc
|
|
| MD5 |
afffd7a2c5197d847c0cb07905774107
|
|
| BLAKE2b-256 |
36a8315342afa718e76f20d4a592ef2a9116fcfa6375126be2d30cf4e138d517
|
File details
Details for the file rleveldb-1.0.0-cp38-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: rleveldb-1.0.0-cp38-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 302.9 kB
- Tags: CPython 3.8+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5aabe9532f3ea80865d04ba94bd5f80e26d06893357107442617260bbd1f552
|
|
| MD5 |
7aa8f72b8293274b565a07286f20deee
|
|
| BLAKE2b-256 |
0275a671f7db445b50a63b15f383b571e043dfd39fae3069b0cc6ef56ae97f17
|