API Reference
This page summarizes the public Python API exposed by pyrex-rocksdb.
PyRocksDB
PyRocksDB(path, options=None, read_only=False) opens a RocksDB database that
uses the default column family.
Methods:
put(key: bytes, value: bytes, write_options=None) -> Noneget(key: bytes, read_options=None) -> bytes | Nonedelete(key: bytes, write_options=None) -> Nonewrite(write_batch: PyWriteBatch, write_options=None) -> Nonewrite_columnar_batch(keys, values, *, write_options=None, on_null="error") -> Nonenew_iterator(read_options=None) -> PyRocksDBIteratorget_options() -> PyOptionsclose() -> None
write_columnar_batch accepts Arrow binary/string arrays or list[bytes] /
tuple[bytes] fallback inputs. It validates lengths and nulls before writing
and applies all rows through one native RocksDB WriteBatch.
PyRocksDBExtended
PyRocksDBExtended extends PyRocksDB with column-family management.
Methods:
put_cf(cf_handle, key: bytes, value: bytes, write_options=None) -> Noneget_cf(cf_handle, key: bytes, read_options=None) -> bytes | Nonedelete_cf(cf_handle, key: bytes, write_options=None) -> Nonelist_column_families() -> list[str]create_column_family(name: str, cf_options=None) -> ColumnFamilyHandledrop_column_family(cf_handle) -> Noneget_column_family(name: str) -> ColumnFamilyHandle | Nonenew_cf_iterator(cf_handle, read_options=None) -> PyRocksDBIteratordefault_cfreturns the default column-family handle.
PyWriteBatch
PyWriteBatch accumulates write operations that are applied atomically with
PyRocksDB.write.
Methods:
put(key: bytes, value: bytes) -> Noneput_cf(cf_handle, key: bytes, value: bytes) -> Nonedelete(key: bytes) -> Nonedelete_cf(cf_handle, key: bytes) -> Nonemerge(key: bytes, value: bytes) -> Nonemerge_cf(cf_handle, key: bytes, value: bytes) -> Noneclear() -> None
PyRocksDBIterator
Iterators traverse keys in RocksDB byte order.
Methods:
valid() -> boolseek_to_first() -> Noneseek_to_last() -> Noneseek(key: bytes) -> Nonenext() -> Noneprev() -> Nonekey() -> bytes | Nonevalue() -> bytes | Nonecheck_status() -> None
Options
PyOptions configures database open options and column-family defaults.
Common properties and methods:
create_if_missingerror_if_existsmax_open_fileswrite_buffer_sizecompressionmax_background_jobscf_write_buffer_sizecf_compressionincrease_parallelism(total_threads)optimize_for_small_db()use_block_based_bloom_filter(bits_per_key=10.0)
WriteOptions configures write operations.
Properties:
syncdisable_wal
ReadOptions configures read operations.
Properties:
fill_cacheverify_checksums
CompressionType
The CompressionType enum exposes RocksDB compression choices, including
kNoCompression, kSnappyCompression, kLZ4Compression, and kZSTD.
Exceptions
RocksDBException is raised for RocksDB operational errors, closed database
usage, invalid column-family handles, and read-only write attempts.