Skip to content

A python-rocksdb wrapper for a more comfortable interaction with RocksDB

License

Notifications You must be signed in to change notification settings

labteral/easyrocks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

easyrocks

A python-rocksdb wrapper for a more comfortable interaction with RocksDB.

Keys must be of type bytes. Values can be nested structures or complex objects. Value serialization is automatically performed with MessagePack if possible, otherwise with Pickle.

Usage

from easyrocks import RocksDB

db = RocksDB(path='./rocksdb', read_only=False)

key = b'key1'
db.put(key, 'one')
db.get(key)
db.exists(key)

for key, value in db.scan(prefix=None, start_key=None, stop_key=None, reversed_scan=False):
  print(key, value)

Utils

There are some useful functions to transform a key to and from bytes:

from easyrocks.utils import (
  str_to_bytes
  bytes_to_str
  int_to_bytes
  bytes_to_int
  str_to_padded_bytes
  int_to_padded_bytes
)