Simple and easy rocksdb client for python
Project description
rocksdb-python
![downloads](https://pypi-camo.freetls.fastly.net/6c216265f0c62610eae43525be58341284a6d67f/68747470733a2f2f696d672e736869656c64732e696f2f707970692f646d2f726f636b7364622d707974686f6e3f7374796c653d666c6174)
Simple and easy rocksdb client for python.
NOTE: This client dosen't fully support rocksdb. Only the basic usage of rocksdb is supported.
Requirements
- python3.8+
- rocksdb
Installation
We need to install and build rocksdb alongside rocksdb-python.
Build rocksdb
From source:
apt-get install build-essential libgflags-dev libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev
git clone https://github.com/facebook/rocksdb.git
cd rocksdb
mkdir build
cd build
make shared_lib
Choose where to install rocksdb after building
-
You can install rocksdb shared library in
/usr/lib/
(systemwide) using:make install-shared INSTALL_PATH=/usr
- If you wish to uninstall it use:
make uninstall INSTALL_PATH=/usr
- If you wish to uninstall it use:
-
If you don't like to install it systemwide you can set the following environment variables which will help the compiler to find rocksdb:
export CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}:`pwd`/../include export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:`pwd` export LIBRARY_PATH=${LIBRARY_PATH}:`pwd`
Install rocksdb-python
Using pip:
pip install rocksdb-python
From source (development version):
pip install git+https://github.com/AYMENJD/rocksdb-python
Usage
import rocksdb, asyncio
async def main():
db = rocksdb.RocksDB(db_path="myrocksdb/", options=rocksdb.Options(create_if_missing=True))
key = "123-456-789"
response = await db.put(rocksdb.WriteOptions(), key, "Hello world. Bye!")
if response.status.ok: # You always need to check if the request success.
get_value = await db.get(rocksdb.ReadOptions(), key)
print(get_value.value) # Hello world. Bye!
await db.delete(rocksdb.WriteOptions(), key)
else:
print(get_value.status.to_dict())
await db.close()
asyncio.run(main())
Check Documentation for more.
Contributing
Pull requests are always welcome!!
License
MIT License
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
Rocksdb-python-0.1.2.dev1.tar.gz
(759.1 kB
view hashes)
Close
Hashes for Rocksdb-python-0.1.2.dev1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 972bb5ecbdbdf95853aef31a6b942d2b7951402d6f9d961a4251c342c5746117 |
|
MD5 | c366ebba88c95fd895ac01bb37171ce6 |
|
BLAKE2b-256 | e9a44b389b1cc71a0239b78278b5ac2c694f851addbe090f74dc19c07fcb9224 |