{"id":15907861,"url":"https://github.com/gau-nernst/rocksdb-python","last_synced_at":"2025-08-28T21:31:59.033Z","repository":{"id":37827777,"uuid":"501558044","full_name":"gau-nernst/rocksdb-python","owner":"gau-nernst","description":"Python bindings for RocksDB. Support Linux, macOS, and Windows","archived":false,"fork":false,"pushed_at":"2023-10-31T10:21:06.000Z","size":18,"stargazers_count":6,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-16T14:12:42.724Z","etag":null,"topics":["pybind11","python","rocksdb"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gau-nernst.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-09T07:56:35.000Z","updated_at":"2024-10-22T21:33:18.000Z","dependencies_parsed_at":"2024-10-28T11:35:50.509Z","dependency_job_id":"8de5a6f7-86bb-40bd-a561-31ec3a917fb0","html_url":"https://github.com/gau-nernst/rocksdb-python","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"41cdbf990c3394bf7e1359b6cdc1ee22e7c54cf5"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gau-nernst%2Frocksdb-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gau-nernst%2Frocksdb-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gau-nernst%2Frocksdb-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gau-nernst%2Frocksdb-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gau-nernst","download_url":"https://codeload.github.com/gau-nernst/rocksdb-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231299795,"owners_count":18354983,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pybind11","python","rocksdb"],"created_at":"2024-10-06T14:05:31.940Z","updated_at":"2024-12-26T02:07:36.147Z","avatar_url":"https://github.com/gau-nernst.png","language":"C++","readme":"# RocksDB Python\n\n[![Build with conda](https://github.com/gau-nernst/rocksdb-python/actions/workflows/build_conda.yaml/badge.svg)](https://github.com/gau-nernst/rocksdb-python/actions/workflows/build_conda.yaml)\n[![Build and Test](https://github.com/gau-nernst/rocksdb-python/actions/workflows/build.yaml/badge.svg)](https://github.com/gau-nernst/rocksdb-python/actions/workflows/build.yaml)\n\nCross-platform Python bindings for [RocksDB](https://github.com/facebook/rocksdb). Other RocksDB Python bindings libraries usually don't provide Windows builds. This repo aims to target all OSes, including Windows.\n\nThis project helps me to learn using C++ libraries in Python with [pybind11](https://github.com/pybind/pybind11).\n\n# Installation\n\n## From wheels\n\nTBD\n\n## From source\n\n### Inside a conda environment (easiest)\n\n[`conda-forge`](https://anaconda.org/conda-forge/rocksdb) provides pre-built RocksDB for Linux x64, MacOS x64 and ARM64, Windows x64.\n\n```bash\n# on Linux and MacOS\nconda install rocksdb -c conda-forge\npip install git+https://github.com/gau-nernst/rocksdb-python.git\n\n# on Windows\nconda install rocksdb zlib -c conda-forge\nLZ4_LIB=liblz4 BZ2_LIB=libbz2 pip install git+https://github.com/gau-nernst/rocksdb-python.git\n```\n\n### With Homebrew (MacOS only)\n\n[Homebrew](https://formulae.brew.sh/formula/rocksdb) provides pre-built RocksDB for MacOS, both x64 and ARM64.\n\n```bash\nbrew install rocksdb\npip install git+https://github.com/gau-nernst/rocksdb-python.git\n```\n\n### Build RocksDB from source\n\nRefer to: https://github.com/facebook/rocksdb/blob/main/INSTALL.md\n\nOn Linux and MacOS, you can install RocksDB's dependencies and compile RocksDB with `make`.\n\n```bash\n# install dependencies on Ubuntu\nsudo apt-get -y install libsnappy-dev zlib1g-dev libbz2-dev liblz4-dev libzstd-dev\n\n# install dependencies on MacOS with Homebrew\nbrew install snappy lz4 zstd  # zlib and bzip2 come with MacOS\n\ngit clone https://github.com/gau-nernst/rocksdb-python\ncd rocksdb-python\ngit clone https://github.com/facebook/rocksdb --branch v8.0.0\nPORTABLE=1 EXTRA_CFLAGS=-fPIC EXTRA_CXXFLAGS=-fPIC make -C rocksdb static_lib -j4\ncp rocksdb/include .\ncp rocksdb/librocksdb.a .\npip install .\n```\n\nBuilding RocksDB on Windows is complicated. vcpkg can help you, but it doesn't allow building Release target from CLI. You can refer to my automated GHA workflow at [.github/workflows/build_rocksdb.yaml](.github/workflows/build_rocksdb.yaml) to see how to build RocksDB (and its dependencies) with CMake.\n\n### Other notes\n\n`setup.py` assumes RocksDB was compiled with all dependencies enabled i.e. snappy, lz4, zlib, zstd, bz2. It will also try to add header paths for compilation and library paths for linking:\n\n- On all platforms: `./rocksdb` for source build; `$CONDA_PREFIX$` for conda libs (automatically added by conda)\n- On Windows: `$CONDA_PREFIX$/Library/` for conda libs\n- On MacOS: `$(brew --prefix)` for Homebrew libs\n\nOn Windows, RocksDB's dependencies library files may have different names depending on how you build them. To link them correctly, specify their names via environment variables.\n\ne.g. with RocksDB installed from conda-forge\n\n```bash\nLZ4_LIB=liblz4 BZ2_LIB=libbz2 pip install .\n```\n\n## My RocksDB build\n\nI write my own GHA workflow [.github/workflows/build_rocksdb.yaml](.github/workflows/build_rocksdb.yaml) to build RocksDB and its dependencies from source. See the Release section for more info.\n\n## Basic usage\n\n```python\nfrom rocksdb_python import Options, PyDB, ReadOptions, WriteOptions\n\noptions = Options()\noptions.IncreaseParallelism()\noptions.create_if_missing = True\n\ndb = PyDB(options, \"./test.db\")\ndb.Put(WriteOptions(), b\"key\", b\"value\")\nv = db.Get(ReadOptions(), b\"key\")\nassert v == b\"value\"\n```\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgau-nernst%2Frocksdb-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgau-nernst%2Frocksdb-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgau-nernst%2Frocksdb-python/lists"}