Skip to main content

Lightweight serverless HTAP engine — Python bindings for the Rhei Rust library

Project description

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-engine on PyPI (the rhei name was already taken), but the import name is rhei:

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rhei_engine-2.0.0.tar.gz (240.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rhei_engine-2.0.0-cp313-cp313-manylinux_2_28_x86_64.whl (60.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

rhei_engine-2.0.0-cp313-cp313-manylinux_2_28_aarch64.whl (59.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

rhei_engine-2.0.0-cp313-cp313-macosx_11_0_arm64.whl (53.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

Details for the file rhei_engine-2.0.0.tar.gz.

File metadata

  • Download URL: rhei_engine-2.0.0.tar.gz
  • Upload date:
  • Size: 240.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for rhei_engine-2.0.0.tar.gz
Algorithm Hash digest
SHA256 90d7390812cca8f92a2359f531ffabe42e324a02e5637d9ca97e2ed6c9741812
MD5 70848e5c2b93f6e63e9c28dd9568d12d
BLAKE2b-256 bb32bee031f5c9687d2aa2d17eef6585071725587a9cf3533a970017f5eb62a5

See more details on using hashes here.

File details

Details for the file rhei_engine-2.0.0-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rhei_engine-2.0.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 62e825e15ff3aae24097207e3a25dc0ab772efc0cd18ff9db71b51ad58b6f7c7
MD5 93a96566b71db483c447fa5499d44805
BLAKE2b-256 4359af6828e5a44f479834ac7a42bada264958f3a90f6fbb0cd31e3837b45cf2

See more details on using hashes here.

File details

Details for the file rhei_engine-2.0.0-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rhei_engine-2.0.0-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b42813ffe6b2718331eb8fef26efb31100ae64e3bab25e9c366b0245b1bb6eb8
MD5 bfae5e452e4eead4a3866d12d12afc8e
BLAKE2b-256 37653f4195357acefdd5c8aec0802f061b7250a612ec36785b8094b16df04040

See more details on using hashes here.

File details

Details for the file rhei_engine-2.0.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rhei_engine-2.0.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8614eba06e21baaa46d3fb55b02c97f0ac4d82bc287c827a9d860f8b9a7a8eb9
MD5 e41242b166ddf89f5dd3ecd8a283bd27
BLAKE2b-256 a9e38983ab1247b1dbd6c615f362d16ba1c846a875c8229a8c8e0e4ddc5715b7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page