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.12.tar.gz (187.4 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.12-cp312-abi3-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.12+Windows x86-64

pyhdb_rs-0.3.12-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.12-cp312-abi3-musllinux_1_2_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.12+musllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.12-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.12-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.12-cp312-abi3-macosx_11_0_arm64.whl (3.1 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

pyhdb_rs-0.3.12-cp312-abi3-macosx_10_12_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for pyhdb_rs-0.3.12.tar.gz
Algorithm Hash digest
SHA256 5e64222ee641ce5d7f400f5eff316b1a9e72336b8bf11851058d7e16d1e7ed17
MD5 abe95ffe6744aec30e7489de56dacb8b
BLAKE2b-256 9847509597f7ec5f3e6bba0e605f88c443982502b77bfbd1749e63f0c3f689ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.12.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.12-cp312-abi3-win_amd64.whl.

File metadata

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

File hashes

Hashes for pyhdb_rs-0.3.12-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0473a1c1ac39d88a904ed8f5d775c68c01a84c158c57b3ed17e2812df2af01a2
MD5 086dafb31bc66327d669a611bc9f4d3e
BLAKE2b-256 215602aadff996e491a371df621c8692051594948d14d4c0a1570ed54bc792d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.12-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.12-cp312-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.12-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 69952527b3213c369857a110472bd13c21d237c49ffd86b9744481ae47d9b1a4
MD5 cfcc455e98d9ce3fe2e67663b1930d38
BLAKE2b-256 b146c47438df8157aa8d229f9ecbeafb710feb6d863ecf75e1078c73aa7046ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.12-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.12-cp312-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.12-cp312-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 28c9bba5a5ad768f3233a8dda74ea848f5fd083dad0ce24e70cf0ea20a91ae43
MD5 d7c4114d9b49c7bad01c2b122f48fc4f
BLAKE2b-256 c19e712d0c21baf5d6c9869c3dd6aa2d1e01f9feee5bdaa85e914f2f4efc02a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.12-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.12-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.12-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 27b6ceb3afc472997bc0dda7eafd98ddbaabc5723e89a31c3b58d14f02748ec3
MD5 7dba9dcf743fe4dc1078336f557ac657
BLAKE2b-256 d704ac6d5d7aaf9be85e0b51998eb7fd0969d473ddb9b804c04de2be9762457c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.12-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.12-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.12-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4d0e3701a314437fcba48fccf7f18b1dfaf791da1db2f71fa3dede8ccd9ea1eb
MD5 cf2da0e72718323a1458c7485e0fc998
BLAKE2b-256 34bc288ea90a694e1de4f9ff46efb59d47ac0467dad9022676617b37b36455a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.12-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.12-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.12-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 083ec8be2d38f67966b63805aceebff5172ea9211b733d6f87f6e59132707b09
MD5 c8e4e818029403f701ad1529afab72bd
BLAKE2b-256 9e3574122205e616ebbf848dd7808d6280ac0297e122a6dec034d76b9c40b6fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.12-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.12-cp312-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.12-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e9ce0f7f5ec1c99580568bbce2b10336e9b5567bfb8e9cd743bbf1eee2e8ea75
MD5 0d4578e66e5c3177123a4ef839fb73e7
BLAKE2b-256 8fc4c89d4894b7c625f52b5dc00090a953b546a3493cc485911323db372afa80

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.12-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

0.3.13

8 files

This release

0.3.12 This release

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