rhei-engine
Python bindings for the Rhei HTAP engine -- lightweight, serverless Hybrid Transactional/Analytical Processing.
All engine methods are async and compatible with asyncio and anyio.
Install
pip install rhei-engine
# or
uv add rhei-engine
Note: the package is published as
rhei-engineon PyPI (therheiname was already taken), but the import name isrhei:import rhei # not "import rhei_engine"
Build from source
cd python
uv sync
uv run maturin develop
Quick start
import anyio
import rhei
async def main():
async with await rhei.open(oltp_path="my.db") as engine:
# Create table and register for CDC replication
await engine.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, age INTEGER)")
await engine.register_table(
rhei.TableSchema("users", [("id", "int64"), ("name", "utf8"), ("age", "int64")], ["id"])
)
# Write (routed to OLTP)
await engine.execute("INSERT INTO users VALUES (1, 'Alice', 30)")
# Batch write (single transaction, ~35K rows/sec)
await engine.execute_batch([
"INSERT INTO users VALUES (2, 'Bob', 25)",
"INSERT INTO users VALUES (3, 'Charlie', 35)",
])
# Sync CDC to OLAP
result = await engine.sync_now()
print(result) # SyncResult(events=3, inserted=3, ...)
# Query (auto-routed: aggregates -> OLAP, point queries -> OLTP)
batches = await engine.query("SELECT AVG(age) FROM users") # list[pyarrow.RecordBatch]
print(batches[0].to_pydict())
anyio.run(main)
API
| Method | Description |
|---|---|
rhei.open(**kwargs) |
Async factory (non-blocking init) |
HtapEngine(config) |
Sync constructor |
engine.execute(sql) |
Write statement (OLTP) |
engine.execute_batch(stmts) |
Batch writes in single transaction |
engine.query(sql) |
Auto-routed query -> list[pyarrow.RecordBatch] |
engine.query_olap(sql) |
Force OLAP query |
engine.sync_now() |
Sync CDC events to OLAP |
engine.register_table(schema) |
Register table for replication |
engine.add_column(t, c, type) |
Add column + rebuild CDC triggers |
engine.drop_column(t, c) |
Drop column |
engine.initial_sync(table) |
Bulk OLTP -> OLAP load |
engine.shutdown() |
Cleanup (resources released on GC) |
License
Apache-2.0
Metadata
Release files for rhei-engine 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rhei_engine-2.0.0.tar.gz | 240.6 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rhei_engine-2.0.0-cp313-cp313-manylinux_2_28_x86_64.whl | CPython 3.13 | CPython 3.13 | Linux glibc 2.28+ x86-64 | Details |
| rhei_engine-2.0.0-cp313-cp313-manylinux_2_28_aarch64.whl | CPython 3.13 | CPython 3.13 | Linux glibc 2.28+ ARM64 | Details |
| rhei_engine-2.0.0-cp313-cp313-macosx_11_0_arm64.whl | CPython 3.13 | CPython 3.13 | macOS 11.0+ ARM64 | Details |
Total release size: 173.3 MB
Release files / rhei_engine-2.0.0.tar.gz
| Download URL | rhei_engine-2.0.0.tar.gz |
|---|---|
| Size | 240.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
90d7390812cca8f92a2359f531ffabe42e324a02e5637d9ca97e2ed6c9741812
|
|
BLAKE2b-256 checksum How to use checksums |
bb32bee031f5c9687d2aa2d17eef6585071725587a9cf3533a970017f5eb62a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.13.3
|
Release files / rhei_engine-2.0.0-cp313-cp313-manylinux_2_28_x86_64.whl
| Download URL | rhei_engine-2.0.0-cp313-cp313-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 60.5 MB |
| Tags | CPython 3.13 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
62e825e15ff3aae24097207e3a25dc0ab772efc0cd18ff9db71b51ad58b6f7c7
|
|
BLAKE2b-256 checksum How to use checksums |
4359af6828e5a44f479834ac7a42bada264958f3a90f6fbb0cd31e3837b45cf2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.13.3
|
Release files / rhei_engine-2.0.0-cp313-cp313-manylinux_2_28_aarch64.whl
| Download URL | rhei_engine-2.0.0-cp313-cp313-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 59.5 MB |
| Tags | CPython 3.13 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
b42813ffe6b2718331eb8fef26efb31100ae64e3bab25e9c366b0245b1bb6eb8
|
|
BLAKE2b-256 checksum How to use checksums |
37653f4195357acefdd5c8aec0802f061b7250a612ec36785b8094b16df04040
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.13.3
|
Release files / rhei_engine-2.0.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | rhei_engine-2.0.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 53.1 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
8614eba06e21baaa46d3fb55b02c97f0ac4d82bc287c827a9d860f8b9a7a8eb9
|
|
BLAKE2b-256 checksum How to use checksums |
a9e38983ab1247b1dbd6c615f362d16ba1c846a875c8229a8c8e0e4ddc5715b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.13.3
|