Skip to main content

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

Project description

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.

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

pyhdb_rs-0.3.5.tar.gz (186.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.5-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl (3.5 MB view details)

Uploaded PyPymusllinux: musl 1.2+ x86-64

pyhdb_rs-0.3.5-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl (3.2 MB view details)

Uploaded PyPymusllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.5-cp314-cp314t-musllinux_1_2_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

pyhdb_rs-0.3.5-cp314-cp314t-musllinux_1_2_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.5-cp313-cp313t-musllinux_1_2_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ x86-64

pyhdb_rs-0.3.5-cp313-cp313t-musllinux_1_2_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.5-cp312-abi3-win_amd64.whl (3.0 MB view details)

Uploaded CPython 3.12+Windows x86-64

pyhdb_rs-0.3.5-cp312-abi3-musllinux_1_2_x86_64.whl (3.5 MB view details)

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

pyhdb_rs-0.3.5-cp312-abi3-musllinux_1_2_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.12+musllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.5-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view details)

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

pyhdb_rs-0.3.5-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

pyhdb_rs-0.3.5-cp312-abi3-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

pyhdb_rs-0.3.5-cp312-abi3-macosx_10_12_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for pyhdb_rs-0.3.5.tar.gz
Algorithm Hash digest
SHA256 cbd991b5c00d9861bc2b7eaab67aea29c5a785154576723e01c199d76778757c
MD5 1bff8edc2397c95a15b5826f43bc5078
BLAKE2b-256 c3ea3dc1a578cdc21154cabe4c5df4bc0677a8ea98d50c9cd5a6f6289fe7dd76

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.5.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.5-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.5-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d10cb43e3b89830b92e2faee4a0dd1e83ea45c3ab46248bfa5b7842e21a17af8
MD5 47ee92f3afc6329987c6285fb8b0dd14
BLAKE2b-256 f72adfbbc22fce571a98a6ba987b76745f1456c35787da60d90eb6e7235658ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.5-pp311-pypy311_pp73-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.5-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.5-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 245b3f6482e20ca65f40d74f7be1e8970e6fb9d79a391e192192f2416fba18de
MD5 579f522a6291574f73be0c48ba721008
BLAKE2b-256 55c0c4050c0a4195c2dded2e1577d7e52cde35d9e7353d1303729111c3d058b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.5-pp311-pypy311_pp73-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.5-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.5-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 cf03c7befd892a500eed4a93a02480e498906c07271c0fe48904a0efa9dad780
MD5 3d904ebea66ebde45a4801870dffd415
BLAKE2b-256 0478dad61d93e7c626c158ba2e9f22f0c8b6f3e696c3357868e69cb710f8d057

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.5-cp314-cp314t-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.5-cp314-cp314t-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.5-cp314-cp314t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 57cfcd8cbea012f235dd6c817784abd62e926b1c285a8f46e1730c2fad8f4f7c
MD5 f8d9d43c8bc0d3b399a9cbbb66ca3007
BLAKE2b-256 d760c3fbab7e83672970bc8ec7d7874cf5cccdbf3bbf295a794b8c1804b43d2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.5-cp314-cp314t-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.5-cp313-cp313t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.5-cp313-cp313t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 86c30a1074b4e54c75e0526031266033103b44f1115c650c5a8bba0ecc776ea8
MD5 85ce443ca5637742e551812293ec2616
BLAKE2b-256 33be33b15d4a2fef61e77755632a4912b09428cbd0c04f5d4abe5810494aaf19

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.5-cp313-cp313t-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.5-cp313-cp313t-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.5-cp313-cp313t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 6c7ea00be52e68edce922bb59d6540ab4567168f6f31ca9df6458a7e949ed9b9
MD5 1665e260d957e4c429ab158d0335c8e3
BLAKE2b-256 d695e6f4856cd839465c8682d99d663b0dffeddde3508c0fbacbd5ed7f8c4e08

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.5-cp313-cp313t-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.5-cp312-abi3-win_amd64.whl.

File metadata

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

File hashes

Hashes for pyhdb_rs-0.3.5-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 33088b4598e43a7d2ad7f1e421e40dd664c41eec23cd36d4443d57e8e471801d
MD5 caeba506497583c911840a567c9fb680
BLAKE2b-256 819924dba9c7624a0eb9ddac95febf704875f877a0b57fcb24509f39aae76eba

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.5-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c7ef4679f2e2a4c72fa63889581d4a2f52980bf5baba52f9c0696990a81411fd
MD5 7d8bfc8a7cbae38350063c3309d6ce3e
BLAKE2b-256 a42459ddb16fc76393ca8a1d450c8f341f98a9963200bf7039ec8178e4bba8e0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.5-cp312-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 56939764150469310b55fc5c07a8e6159b16807f1b37a1eb6ffd0ac0edd25377
MD5 5e5c44ae91e450654fad997e87f6baa5
BLAKE2b-256 acdbd2d2596acfe90b03b3f0c7730dba9ebd20d2608af98af8783955b3e6fbcd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.5-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a59befe8206d293e8802fd054a1a46b7a860e3c460d283798ddab9db307c5ab6
MD5 044a2544edd17f2ba89ec40885cedc41
BLAKE2b-256 d1aa467281be2c0ae6a473373a5a9ec44250ff29a32e5fc20553a9a788f8a88b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.5-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d7dcca96ced0f7ea5ca24cec5207a4360c195feba2d8815cc0ddcd71b6264198
MD5 5f2652b1db4e32bc97f1aa7dcd65a60b
BLAKE2b-256 ea870ce06d587e6e817cb07d27f7619ee93a98df053b48634018091a01201225

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.5-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e54f7cf311da95bf9a9f51191f26df14cfe8bff836d7bd14bda3ac46e3769b9c
MD5 72b52037e0c61b2e3f7aca68a8d92ed2
BLAKE2b-256 1206de32f06ebf2a1fd7fabb06b7ce22a1d9e582bae31cacc231b6e0cfcf1790

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.5-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7ae079a31c33f15bfeb43c3a9becd729ffcd7923410a314c44a58b11b706162a
MD5 461fc35ed629876ceb224117b2132b14
BLAKE2b-256 23cc8c935aeddfd3b35a0fcd890873ef3dcafcffd4aa5c791bd335ce8fb87896

See more details on using hashes here.

Provenance

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

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