Skip to main content

Python bindings for RocksDB

Project description

rocksdb-py

Python bindings for RocksDB written in Rust.

Features

  • Get, set, delete, multi get
  • Destroy
  • Batch write
  • Database iterator
  • Read options

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rocksdb_py-0.0.5.tar.gz (54.1 kB view details)

Uploaded Source

Built Distributions

rocksdb_py-0.0.5-cp311-none-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.11 Windows x86-64

rocksdb_py-0.0.5-cp311-cp311-manylinux_2_31_x86_64.whl (4.7 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.31+ x86-64

rocksdb_py-0.0.5-cp311-cp311-macosx_11_0_arm64.whl (2.9 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

rocksdb_py-0.0.5-cp311-cp311-macosx_10_14_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.11 macOS 10.14+ x86-64

rocksdb_py-0.0.5-cp310-none-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.10 Windows x86-64

rocksdb_py-0.0.5-cp310-cp310-manylinux_2_31_x86_64.whl (4.7 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.31+ x86-64

rocksdb_py-0.0.5-cp310-cp310-macosx_11_0_arm64.whl (2.9 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

rocksdb_py-0.0.5-cp310-cp310-macosx_10_14_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.10 macOS 10.14+ x86-64

rocksdb_py-0.0.5-cp39-none-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.9 Windows x86-64

rocksdb_py-0.0.5-cp39-cp39-manylinux_2_31_x86_64.whl (4.7 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.31+ x86-64

rocksdb_py-0.0.5-cp39-cp39-macosx_11_0_arm64.whl (2.9 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

rocksdb_py-0.0.5-cp39-cp39-macosx_10_14_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.9 macOS 10.14+ x86-64

File details

Details for the file rocksdb_py-0.0.5.tar.gz.

File metadata

  • Download URL: rocksdb_py-0.0.5.tar.gz
  • Upload date:
  • Size: 54.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.18

File hashes

Hashes for rocksdb_py-0.0.5.tar.gz
Algorithm Hash digest
SHA256 9ccc51a6e4350d766381bf996a5231331807988ea18a2062c28c4537dbf47fec
MD5 36a53c15c259f297cd67ef4dc90a1430
BLAKE2b-256 e1989806f3aa7fc64be2ef1edecc9d9f3e874294b9f06dc7f4e9b6c5723c4b1c

See more details on using hashes here.

File details

Details for the file rocksdb_py-0.0.5-cp311-none-win_amd64.whl.

File metadata

File hashes

Hashes for rocksdb_py-0.0.5-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 f1e332fc8f3427920edfa9db3346c12c9cb2f88a0561aa9598fb5f0dcd71e430
MD5 227a8d942275becb19d2645c741f6b6e
BLAKE2b-256 d828dfaa32ea63cf88a083350c9d5e80d9e80817b2374ac8f7c1d0b75f1bb6cb

See more details on using hashes here.

File details

Details for the file rocksdb_py-0.0.5-cp311-cp311-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for rocksdb_py-0.0.5-cp311-cp311-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 470e26aff4a89f91bdf874e53faf30f314e2c025a5510223e9bcd2ec9e76e3d8
MD5 435cfcdddea91001018d71facfcce06d
BLAKE2b-256 695ee7f8397613ed7f6e3b0b8547ab361173bc3a240aec06591e95450648d2d9

See more details on using hashes here.

File details

Details for the file rocksdb_py-0.0.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rocksdb_py-0.0.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 689b64c5ebe81ea908f6924b1683c99553d9c2ea53a55697f903ed1d4d57b92a
MD5 ced0adf10f7a79ee2fd4c4fafed49db8
BLAKE2b-256 909367ac7d013a8182c45c614a53cd23efa46bd91583c856ff33462fa94e6524

See more details on using hashes here.

File details

Details for the file rocksdb_py-0.0.5-cp311-cp311-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for rocksdb_py-0.0.5-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 785a40df814540d3cfc6713d4ca88a9e9f40ac1546dfb9baff624eace3c5e520
MD5 1af72f46a4f69048288f62dd9026c0a9
BLAKE2b-256 75d3785783f4ac3e04d7a982f1bae5482cdbb463e56f9215086d77ce001cae4c

See more details on using hashes here.

File details

Details for the file rocksdb_py-0.0.5-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for rocksdb_py-0.0.5-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 1b843d5302836a148f39065badf75786e1db470a485c2667c2e7d0904614e371
MD5 9b573dc954fd94e05fea0231c6bb9d9d
BLAKE2b-256 bfb432187c5fb228baf1f19766f3bb812293e22d657a299560f1d0c1cdd43395

See more details on using hashes here.

File details

Details for the file rocksdb_py-0.0.5-cp310-cp310-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for rocksdb_py-0.0.5-cp310-cp310-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 3d05a80e5bac8e6b1c54f3eac9b4fbf15767557eb963676fc4a6888ac3259743
MD5 951c060de0400b84b51f72f7407a2f4f
BLAKE2b-256 6883b7ae81b5c58fd5a775cc2e8a671578f31f8a8077afd36ea4d66c36c69150

See more details on using hashes here.

File details

Details for the file rocksdb_py-0.0.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rocksdb_py-0.0.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 55ec77a0c548eeb9a9418081e328a2ea82f82b7679eb36bbfa0eeefc2aa5ef07
MD5 24ef0792b53bfb4708bef97134f4e33e
BLAKE2b-256 e85756189314c592f9bf649a4a35065682a95482218159e499b0a2769fbe2fd5

See more details on using hashes here.

File details

Details for the file rocksdb_py-0.0.5-cp310-cp310-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for rocksdb_py-0.0.5-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 7015b010bc43a84ae0d76dab402ed770c7bf8f302db7ac1ce511f0f79874f376
MD5 ed77052845848c20775fda2f2a3b36a4
BLAKE2b-256 4915dc775b1fee8041ad12f6d481ff0a56d6b04e9a5bc6bd4f56eb3cebf47d2a

See more details on using hashes here.

File details

Details for the file rocksdb_py-0.0.5-cp39-none-win_amd64.whl.

File metadata

File hashes

Hashes for rocksdb_py-0.0.5-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 f02bcf5869b1d88c294697cae01aac15c44611237e9eb9c775ef33e24514e7c8
MD5 ae762f2293dfb8a9d02a081ad88a450b
BLAKE2b-256 e39096f430957fe59ff6cfc15afa333b160e3844830753e2293ab4b13de1317f

See more details on using hashes here.

File details

Details for the file rocksdb_py-0.0.5-cp39-cp39-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for rocksdb_py-0.0.5-cp39-cp39-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 6a73fb07efcbcfdb902fcd6ba32edd9f3386621d6b89e2e2921774c7d5fc9c84
MD5 cad66175e62d9279b2ec3e0580cd6aa0
BLAKE2b-256 6938755ac17351c085e71f130cbe94b7428392b1145de66cd9af96fecdfdfd71

See more details on using hashes here.

File details

Details for the file rocksdb_py-0.0.5-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rocksdb_py-0.0.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 262c41d68f5f98d5fae5e33c16fd9e53fba506f1cd0b20514d36f144caf0d7b2
MD5 c50045694cff4c5605d412d764620a97
BLAKE2b-256 a1f237f312989d8212ea4afd11e7f91140a38495c6d29d465715b4b506849c07

See more details on using hashes here.

File details

Details for the file rocksdb_py-0.0.5-cp39-cp39-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for rocksdb_py-0.0.5-cp39-cp39-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 bea6d965aadb5b1815c132521f2ef3b3acc344d72b60eca8d33871181fef0525
MD5 67fa0f435dc49c547eca8e76a26fb948
BLAKE2b-256 4cd720eb8d9eda7e854bf5798c32ab36fdbae2f1df83bfeeff8949da3f447b41

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page