rocksdb-py
Python bindings for RocksDB written in Rust.
Features
- Get, set, delete, multi get
- Destroy
- Batch write
- Database iterator
- Read options
- Backup DB
Install
To install a wheel from PyPI,
pip install --upgrade rocksdb-py
or if you want to build a wheel, see build.
Usage
Open database
Open a database with default options.
import rocksdbpy
db = rocksdbpy.open_default('/tmp/rocksdb')
Open a database with the specified options.
opts = Option()
opts.create_if_missing(True)
db = rocksdbpy.open('/tmp/rocksdb', opts)
Open a database with TTL compaction filter.
opts = Option()
opts.create_if_missing(True)
db = rocksdbpy.open_with_ttl('/tmp/rocksdb', 5, opts)
Destroy the database and it's files.
rocksdbpy.destroy('/tmp/rocksdb')
Close active database and release lock.
db.close()
Simple read, set and delete
Set records by key and value.
db.set(b'key', b'value')
Get a value associated with a key.
value = db.get(b'key')
Remove existing records by key.
db.delete(b'key')
Batch write, database iterator and flush
Set database entries for list of key and values as a batch.
from rocksdbpy import WriteBatch
batch = WriteBatch()
batch.add(b'first', b'1')
batch.add(b'second', b'2')
db.write(batch)
Extra operations for the batch.
batch.delete(b'first')
batch.clear()
size = batch.len()
Return a heap-allocated iterator over the contents of the database.
iterator = db.iterator()
iterator = db.iterator(mode='end')
iterator = db.iterator(mode='from', key=b'test')
iterator = db.iterator(mode='from', key=b'test', direction=-1)
for key, value in iterator:
print(key, value)
Flush database memtables to SST files on the disk using default options.
db.flush()
Read options
Set database read options.
opts = Option()
opts.create_if_missing(True)
opts.set_max_open_files(10)
opts.set_use_fsync(True)
opts.set_bytes_per_sync(1024 * 1024)
# and more
Backup and Restore
You can create a backup of your database
db.create_backup('/tmp/backup_rocksdb')
Please note, this is NOT A DATABASE! This is a backup, it will need to be restored.
from rocksdbpy import RocksDB
RocksDB.restore_latest_backup('/tmp/backup_rocksdb', '/tmp/new_rocksdb')
opts.create_if_missing(True)
db_restore = rocksdbpy.open('/tmp/new_rocksdb', opts)
Build
You can build PIP package by using maturin. The example below is created for MacOS,
$ git clone https://github.com/trk54ylmz/rocksdb-py.git
$ cd rocksdb-py
$ maturin build
$ pip3 install ./target/wheels/rocksdb_py-0.0.1-cp39-cp39-macosx_11_0_arm64.whl
Metadata
Release files for rocksdb-py 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 37.6 MB
Release files / rocksdb_py-0.0.7-cp313-cp313-win_amd64.whl
| Download URL | rocksdb_py-0.0.7-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 3.0 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
7fcd646b285201250718bfa6cc3294890acfe17bb2cf8f48a11feadd87e9c07d
|
|
BLAKE2b-256 checksum How to use checksums |
a95c7145a0250abf722c4d56090afec1ec09af50b7dc070c5132307ac5dad1d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|
Release files / rocksdb_py-0.0.7-cp313-cp313-macosx_13_0_x86_64.whl
| Download URL | rocksdb_py-0.0.7-cp313-cp313-macosx_13_0_x86_64.whl |
|---|---|
| Size | 3.8 MB |
| Tags | CPython 3.13 macOS 13.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
4c772034b1091b9347631b3dcd9ead65a4372b26a652ea3c2a6d048d6e909ae2
|
|
BLAKE2b-256 checksum How to use checksums |
d80745a4bde210556f0be39723e99e6b06a16a68d2cd5b937c4642700095cf62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|
Release files / rocksdb_py-0.0.7-cp312-cp312-win_amd64.whl
| Download URL | rocksdb_py-0.0.7-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 3.0 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d0671895860c7d21c2fa0caf94559ca324b4ba102b3a0b55e2d1ca9caf196dc4
|
|
BLAKE2b-256 checksum How to use checksums |
3677ef88a6957573d4340b9d90d8da0c237840ecbc65c23f8fa798ebfae5ae5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|
Release files / rocksdb_py-0.0.7-cp312-cp312-macosx_13_0_x86_64.whl
| Download URL | rocksdb_py-0.0.7-cp312-cp312-macosx_13_0_x86_64.whl |
|---|---|
| Size | 3.8 MB |
| Tags | CPython 3.12 macOS 13.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
31fb4b9de1a0f38f5ace25ee73091850b292bc8a771003e4b40b20d699054d3b
|
|
BLAKE2b-256 checksum How to use checksums |
5a0d546bd200132cce16ae96868638958716568df991776b9b78de54b4b5b86f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|
Release files / rocksdb_py-0.0.7-cp311-cp311-win_amd64.whl
| Download URL | rocksdb_py-0.0.7-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 3.0 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
11c2d78b53b2185a91a4185394cab14cb8c2975d3e80c9440b482e455e32ceef
|
|
BLAKE2b-256 checksum How to use checksums |
48c273d2ba74029b184ef83b86ca79112cd6f03a4be914777868a48d5a8f60e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|
Release files / rocksdb_py-0.0.7-cp311-cp311-macosx_13_0_x86_64.whl
| Download URL | rocksdb_py-0.0.7-cp311-cp311-macosx_13_0_x86_64.whl |
|---|---|
| Size | 3.8 MB |
| Tags | CPython 3.11 macOS 13.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
c2afd47c1d14c6fb5d5a8e45ff12b7b0041aa37ef9a01e443fba30a824500d09
|
|
BLAKE2b-256 checksum How to use checksums |
d350428b156c58d48e854fe5c5875276fa3feff60d81b773b2c93a5747d1fd3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|
Release files / rocksdb_py-0.0.7-cp310-cp310-win_amd64.whl
| Download URL | rocksdb_py-0.0.7-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 3.0 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
f6f18ed5fe2250878ede0d21cbad37cc20a0ae6f880cb7e052f347d76511571b
|
|
BLAKE2b-256 checksum How to use checksums |
af84e759c5869c211687b63cc326a6fc0daeabd175ba2e13d0cb53629f6b9922
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|
Release files / rocksdb_py-0.0.7-cp310-cp310-macosx_13_0_x86_64.whl
| Download URL | rocksdb_py-0.0.7-cp310-cp310-macosx_13_0_x86_64.whl |
|---|---|
| Size | 3.8 MB |
| Tags | CPython 3.10 macOS 13.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
e3888859f1d2045b1983a9434cf89722c09d850ac3d6e185e06f5c57e021a04d
|
|
BLAKE2b-256 checksum How to use checksums |
bd5c1b735fabd5589bf5fdae308fa63a3e1e182063b2d35f2941b2a3c7e0532c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|
Release files / rocksdb_py-0.0.7-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | rocksdb_py-0.0.7-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
8be31335fa73891ffc68edb3b28adc4976ae355746b08b0fa909ccf44037bc81
|
|
BLAKE2b-256 checksum How to use checksums |
908c479f79b203c6645c0a013020757fc992263fcf16dcbd72047a4a6e6a3b46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|
Release files / rocksdb_py-0.0.7-cp39-cp39-win_amd64.whl
| Download URL | rocksdb_py-0.0.7-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 3.0 MB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ba68baca2ed43fc243c7bfa8211fa6d9177355f0b39bd6b468503fa9672867a8
|
|
BLAKE2b-256 checksum How to use checksums |
f8427e8f3301d39c480cfa0010e12b2f9cf0abded87aee8994a05d309c0bf24a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|
Release files / rocksdb_py-0.0.7-cp39-cp39-macosx_13_0_x86_64.whl
| Download URL | rocksdb_py-0.0.7-cp39-cp39-macosx_13_0_x86_64.whl |
|---|---|
| Size | 3.8 MB |
| Tags | CPython 3.9 macOS 13.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
69517213169c77ce8493f1a656108f1c214d04ce1fb76ad10f48b41ec9bc091e
|
|
BLAKE2b-256 checksum How to use checksums |
2282bb015fc71f4f6dc5b0e6275a6cb1e3b6be7def75479d8bea49ec5d46a4e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.23
|
Security for rocksdb-py 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.