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-1.5.1.tar.gz (193.8 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-1.5.1-cp313-cp313-manylinux_2_28_x86_64.whl (53.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

rhei_engine-1.5.1-cp313-cp313-manylinux_2_28_aarch64.whl (52.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

rhei_engine-1.5.1-cp313-cp313-macosx_11_0_arm64.whl (46.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for rhei_engine-1.5.1.tar.gz
Algorithm Hash digest
SHA256 3309d8b6fa6e4ead176de062534b8fe81a4917ba13b572cc1ba448d572a91c89
MD5 5f631e23c6ce677fa10733cf3a69bd52
BLAKE2b-256 47f8c1977e1959397a0f8a63007a0fb182dc9ec517245a3fe89567da31913fd4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rhei_engine-1.5.1-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2e914481fcd61d050d847f8de8a30c287d6dfeb8165793ad2afe234aca3c21e1
MD5 2950bb875de3144c50a216caf23d403d
BLAKE2b-256 9a6dfd423439fa223464612abb749d60a15f6b0c3903bdbdf647886d83201b5d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rhei_engine-1.5.1-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e58bc681b876d1687c292ab60d9a7ce6ba2f9124a7c36f66b16760dd538704d4
MD5 00b7beed04bf4ba0a6e190f7c54277fe
BLAKE2b-256 4090a6e785a7075cad41b6c40ebbdf00ffcc12f42ee6a4e3a849dcc2ba20f093

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rhei_engine-1.5.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2d8d0f36598811dc9cf214b7ab1201af8e665419da530cd8431f72d69e4266f1
MD5 3c8e4194f77348e3dd785dbf4970d325
BLAKE2b-256 468aadfddbf48cef5c99a2b798bfb3ef370bb5c56e50ad58aef3706762f20c32

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