Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aymenjd/rocksdb-python
Easy-to-use asynchronous rocksdb client for python.
https://github.com/aymenjd/rocksdb-python
async asyncio client database pybind11 python python3 rocksdb
Last synced: 7 days ago
JSON representation
Easy-to-use asynchronous rocksdb client for python.
- Host: GitHub
- URL: https://github.com/aymenjd/rocksdb-python
- Owner: AYMENJD
- License: mit
- Created: 2022-11-13T18:28:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-11T09:06:13.000Z (over 1 year ago)
- Last Synced: 2024-08-10T07:35:35.287Z (6 months ago)
- Topics: async, asyncio, client, database, pybind11, python, python3, rocksdb
- Language: C++
- Homepage:
- Size: 21.5 KB
- Stars: 13
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rocksdb-python [](https://pypi.org/project/rocksdb-python) [](https://pypistats.org/packages/rocksdb-python)
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](https://github.com/facebook/rocksdb)Installation
------------We need to [install](https://github.com/facebook/rocksdb/blob/master/INSTALL.md) and build rocksdb alongside rocksdb-python.
Build rocksdb
-------------From source:
***********
```bash
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:
```bash
make install-shared INSTALL_PATH=/usr
```
- If you wish to uninstall it use:
```bash
make uninstall INSTALL_PATH=/usr
```- If you don't like to install it systemwide you can set the following environment variables which will help the compiler to find rocksdb:
```bash
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:
```bash
pip install rocksdb-python
```From source (development version):
```bash
pip install git+https://github.com/AYMENJD/rocksdb-python
```Usage
-----
```python
import rocksdb, asyncioasync 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](https://github.com/AYMENJD/rocksdb-python/wiki) for more.Contributing
------------
Pull requests are always welcome!!License
-------MIT [License](https://github.com/AYMENJD/rocksdb-python/blob/main/LICENSE)