Skip to main content

pyhdb-rs

PyPI Python codecov CI License

High-performance Python driver for SAP HANA with native Apache Arrow support.

Features

  • DB-API 2.0 compliant - Drop-in replacement for existing HANA drivers
  • Zero-copy Arrow integration - Direct data transfer to Polars and pandas
  • Async support - Native async/await with connection pooling
  • Type-safe - Full type hints and strict typing
  • Fast - Built with Rust for 2x+ performance over hdbcli

Installation

pip install pyhdb_rs

With optional dependencies:

pip install pyhdb_rs[async]     # Async support

For DataFrame libraries, install separately:

pip install polars              # Polars DataFrame library
pip install pandas pyarrow      # pandas with Arrow support

Tip: Use uv pip install pyhdb_rs for faster installation.

Quick start

from pyhdb_rs import ConnectionBuilder
import polars as pl

conn = ConnectionBuilder.from_url("hdbsql://USER:PASSWORD@HOST:39017").build()
reader = conn.execute_arrow("SELECT * FROM SALES_ORDERS WHERE ORDER_STATUS = 'SHIPPED'")
df = pl.from_arrow(reader)
print(df)
conn.close()

Usage

Polars integration

from pyhdb_rs import ConnectionBuilder
import polars as pl

conn = ConnectionBuilder.from_url("hdbsql://USER:PASSWORD@HOST:39017").build()
reader = conn.execute_arrow(
    """SELECT PRODUCT_NAME, SUM(QUANTITY) AS TOTAL_SOLD, SUM(NET_AMOUNT) AS REVENUE
       FROM SALES_ITEMS
       WHERE FISCAL_YEAR = 2025 AND REGION = 'EMEA'
       GROUP BY PRODUCT_NAME
       ORDER BY REVENUE DESC"""
)
df = pl.from_arrow(reader)
print(df.head())
conn.close()

pandas integration

from pyhdb_rs import ConnectionBuilder
import pyarrow as pa

conn = ConnectionBuilder.from_url("hdbsql://USER:PASSWORD@HOST:39017").build()
reader = conn.execute_arrow(
    """SELECT c.CUSTOMER_NAME, COUNT(o.ORDER_ID) AS ORDER_COUNT, SUM(o.TOTAL_AMOUNT) AS TOTAL_SPENT
       FROM CUSTOMERS c
       JOIN SALES_ORDERS o ON c.CUSTOMER_ID = o.CUSTOMER_ID
       WHERE o.ORDER_DATE >= '2025-01-01'
       GROUP BY c.CUSTOMER_NAME
       HAVING SUM(o.TOTAL_AMOUNT) > 5000"""
)
pa_reader = pa.RecordBatchReader.from_stream(reader)
df = pa_reader.read_all().to_pandas()
print(df)
conn.close()

Async support

The async API provides full async/await support with connection pooling.

import asyncio
import polars as pl
from pyhdb_rs.aio import AsyncConnectionBuilder


async def main():
    conn = await (
        AsyncConnectionBuilder().host("hana.example.com").credentials("USER", "PASSWORD").build()
    )

    async with conn:
        reader = await conn.execute_arrow(
            """SELECT PRODUCT_CATEGORY, COUNT(*) AS ITEM_COUNT, SUM(NET_AMOUNT) AS TOTAL_REVENUE
               FROM SALES_ITEMS
               WHERE ORDER_DATE >= '2025-01-01'
               GROUP BY PRODUCT_CATEGORY"""
        )
        df = pl.from_arrow(reader)
        print(df)


asyncio.run(main())

Note: Use async with for proper resource cleanup. The context manager automatically closes the connection on exit.

Connection pooling

import asyncio
import polars as pl
from pyhdb_rs.aio import create_pool

pool = create_pool("hdbsql://USER:PASSWORD@HOST:39017", max_size=10, connection_timeout=30)


async def handle_request(customer_id: int):
    async with pool.acquire() as conn:
        reader = await conn.execute_arrow(
            f"""SELECT o.ORDER_ID, o.ORDER_DATE, o.TOTAL_AMOUNT, o.ORDER_STATUS
                FROM SALES_ORDERS o
                WHERE o.CUSTOMER_ID = {customer_id} AND o.ORDER_DATE >= '2025-01-01'
                ORDER BY o.ORDER_DATE DESC"""
        )
        return pl.from_arrow(reader)


# Run concurrent queries
results = await asyncio.gather(handle_request(1001), handle_request(1002), handle_request(1003))

Error handling

from pyhdb_rs import ConnectionBuilder, DatabaseError, InterfaceError

try:
    conn = ConnectionBuilder.from_url("hdbsql://USER:PASSWORD@HOST:39017").build()
    cursor = conn.cursor()
    cursor.execute(
        "SELECT CUSTOMER_NAME, EMAIL FROM CUSTOMERS WHERE REGISTRATION_DATE >= ?", ["2025-01-01"]
    )
except DatabaseError as e:
    print(f"Database error: {e}")
except InterfaceError as e:
    print(f"Connection error: {e}")

Type hints

This package is fully typed and includes inline type stubs:

from pyhdb_rs import ConnectionBuilder, Connection, Cursor


def query_data(uri: str, status: str) -> list[tuple[int, str, str]]:
    conn = ConnectionBuilder.from_url(uri).build()
    cursor: Cursor = conn.cursor()
    cursor.execute(
        "SELECT ORDER_ID, CUSTOMER_NAME, ORDER_STATUS FROM SALES_ORDERS WHERE ORDER_STATUS = ?",
        [status],
    )
    result = cursor.fetchall()
    conn.close()
    return result

Requirements

  • Python >= 3.12

Development

git clone https://github.com/bug-ops/pyhdb-rs
cd pyhdb-rs/python

pip install -e ".[dev]"

pytest
ruff check .
mypy .

Documentation

See the main repository for full documentation.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Download files

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

Source Distribution

pyhdb_rs-0.3.13.tar.gz (185.9 kB view details)

Uploaded Source

Built Distributions

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

pyhdb_rs-0.3.13-cp312-abi3-win_amd64.whl (3.3 MB view details)

Uploaded CPython 3.12+Windows x86-64

pyhdb_rs-0.3.13-cp312-abi3-musllinux_1_2_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.12+musllinux: musl 1.2+ x86-64

pyhdb_rs-0.3.13-cp312-abi3-musllinux_1_2_aarch64.whl (3.6 MB view details)

Uploaded CPython 3.12+musllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.13-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ x86-64

pyhdb_rs-0.3.13-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.5 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

pyhdb_rs-0.3.13-cp312-abi3-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

pyhdb_rs-0.3.13-cp312-abi3-macosx_10_12_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

Details for the file pyhdb_rs-0.3.13.tar.gz.

File metadata

  • Download URL: pyhdb_rs-0.3.13.tar.gz
  • Upload date:
  • Size: 185.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pyhdb_rs-0.3.13.tar.gz
Algorithm Hash digest
SHA256 6ef0b8d064ae25213c1137c00478c1f9bf510af3a4ee70c3eaf009f3b3334dd7
MD5 b7bba3af53b4607b873995854ab3c3c7
BLAKE2b-256 f744536c483d3be5cdebc5d1d6b1e312de78f492e69b2701f891a8a476070430

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.13.tar.gz:

Publisher: release.yml on bug-ops/pyhdb-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyhdb_rs-0.3.13-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: pyhdb_rs-0.3.13-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.3 MB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pyhdb_rs-0.3.13-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7ac409961c6be9945b382645cc2a03a014eb9034c1d412acae5505bcd204928d
MD5 66e11eb985e25ce20561cdc734c9f51b
BLAKE2b-256 87e5750e7ef9ccdac72c35e384143475fb9c1b812af52f9065e861f1c2e21f45

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.13-cp312-abi3-win_amd64.whl:

Publisher: release.yml on bug-ops/pyhdb-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyhdb_rs-0.3.13-cp312-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.13-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 14bedd0ceb6d783e2a63a01dc2cbb66a9efe7dab994bdd444b423a751e702834
MD5 803c8173c750c12878e6e2b47dcad19f
BLAKE2b-256 739f73cc5b198220dd2bf158ac622847ebbbc5465ddb590810dee65765e85009

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.13-cp312-abi3-musllinux_1_2_x86_64.whl:

Publisher: release.yml on bug-ops/pyhdb-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyhdb_rs-0.3.13-cp312-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.13-cp312-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 9131a44c3a0ef02538afd5b8884937656a5462a9c8edddf77cbf7cbbcbb8447b
MD5 78cb6d43fa14d7dca8df27430a1e8981
BLAKE2b-256 62121ae397f5063f75859a21ffd7453a70d203c21540b8d7f55859002509c44d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.13-cp312-abi3-musllinux_1_2_aarch64.whl:

Publisher: release.yml on bug-ops/pyhdb-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyhdb_rs-0.3.13-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.13-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 81aae24bdcf2ce722410e1325866a2a85681bac7f1fffd00dab0bd440ba20d83
MD5 83c24460823669b9c680fb064355c3e4
BLAKE2b-256 3796e733c32dfdc0606858ee0a4d9b22fdfb38e624afa04b922b9b5c7de68ba5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.13-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on bug-ops/pyhdb-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyhdb_rs-0.3.13-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.13-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2c9ddb740eb535ba37b81507cc3b8458c00b59ae80f8b4d4f478d093cc38c623
MD5 e8dd3cb9b9b0d623ef7346aff2b1c9c4
BLAKE2b-256 3586dd0e24c427e954bcabaed9683e815ba1c8283abcb529e77d441ec7355f3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.13-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on bug-ops/pyhdb-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyhdb_rs-0.3.13-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.13-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8b0395583410c6a7bfb96d961072228601fc92c14e08260db3dc81d524b90f0f
MD5 e653471ea1c944b1b70bb12c1461151b
BLAKE2b-256 d73ce5aee8180aae6b744408daa5230cb4d3c146acd5a91ae41f8c8fff2d404f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.13-cp312-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on bug-ops/pyhdb-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyhdb_rs-0.3.13-cp312-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.13-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 22b0d229f809792228362f6b36dfb3a61b0b7e4ed565fcb05e1d6ef2be3f245b
MD5 f0484ba44abd4fdddbeab88bd5a55c24
BLAKE2b-256 908924d6a4579133f73cb67cce09e7b81bd30f877142fff9ac5d04811453cb99

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.13-cp312-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on bug-ops/pyhdb-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.3.13 This release

8 files

0.3.12

8 files

0.3.11

8 files

0.3.10

8 files

0.3.9

14 files

0.3.8

14 files

0.3.7

14 files

0.3.6

14 files

0.3.5

14 files

0.3.4

14 files

0.3.3

14 files

0.3.2

14 files

0.3.1

14 files

0.3.0

14 files

0.2.4

14 files

0.2.3

14 files

0.2.1

14 files

0.2.0

14 files

0.1.3

14 files

0.1.2

6 files

0.1.1

6 files

0.1.0

2 files

Supported by

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