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.9.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.9-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.9-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl (3.3 MB view details)

Uploaded PyPymusllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.9-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.9-cp314-cp314t-musllinux_1_2_aarch64.whl (3.3 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.9-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.9-cp313-cp313t-musllinux_1_2_aarch64.whl (3.3 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.12+Windows x86-64

pyhdb_rs-0.3.9-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.9-cp312-abi3-musllinux_1_2_aarch64.whl (3.3 MB view details)

Uploaded CPython 3.12+musllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.9-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.9-cp312-abi3-macosx_11_0_arm64.whl (2.8 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

pyhdb_rs-0.3.9-cp312-abi3-macosx_10_12_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

pyhdb_rs-0.3.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: pyhdb_rs-0.3.9.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.9.tar.gz
Algorithm Hash digest
SHA256 0652b7e631b9aa6d6ec0426e9376fc673d0a854a51c4fe1d74a7a91649e0dfac
MD5 18582f29e3dbffe3f445c9057a253946
BLAKE2b-256 09d9a4a066f320a042103d877922158d17126ed56a82d79516fc5d4a9ef9da2c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.9-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a1a5197647080907abe97e7e85f61f6f6ce535cdd448e2547b930f26ee482148
MD5 eaf9eba1a66e45666a48bfcfc17b6e7a
BLAKE2b-256 b90f36608c006dd6d759b5904af21d92f9fe7a529a5aeb8188bf6b9ba8d1cbf0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.9-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 018682819065f95eda98e1dfd807b0b3f2e2f0513385f8cf8b87e65954a360c0
MD5 3c297c8c807771d32cc5eb5ee5696e59
BLAKE2b-256 0a47415400736288e2c0b11f20a3775849a537df1a8fb7517d8e35a06aba5ee5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.9-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.9-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.9-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a5f02f4106b3e6e1cb7b44e4abb846b61dd4c3bd79d870546b6acfd97eb94977
MD5 a6abbfc3424867208dde7359ca9254a5
BLAKE2b-256 6f91c6d7966c105644d8b1bbe3bfc6821c41583237ce8ad0b835347f6fdcb5dc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.9-cp314-cp314t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 03288d2c2729fae4dda89187facf735348c2815259f056769bdeb0c9e1010283
MD5 80cd2bcf55bb7bbb774115a85ab232f0
BLAKE2b-256 5504ee46a4a29ee2d24243e952b8a6fe211f1fab188961c85394efb679e2ff77

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.9-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.9-cp313-cp313t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.9-cp313-cp313t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e1e16a2b87e056cec37d20d36963aadb072e647ece158038f335a312ca43207f
MD5 79fd412480c459dfcd7b183f39425c37
BLAKE2b-256 cf3c8ce6e1ebd24597d3cc54ab9160c63fbf43637f3a4b586159d0431dd8b653

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.9-cp313-cp313t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 77a9837b76fd874f96a5b0e1d972a9f1fe355d7e6c708788a0a6e5d11d6691b0
MD5 9d91b41cfd5c596a888eaf569905a9da
BLAKE2b-256 a1e27a07d0b14ec019312f2e3298153d051edb086f830d0efa00b09b1e336979

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyhdb_rs-0.3.9-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.9-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3a43fcf2d2eb4ca1f13d0bba6629c19d9de288ac4def0cfbedf1edd37e98f9d1
MD5 b1c3a904f53e0a53677248c09bb0c065
BLAKE2b-256 9b8badd5a3f200e1d2e620b3df7062ff92080c1bfa260338f4f20b4e7851cf08

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.9-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 16552e483b2634fbbfc82445cbfc5926daa6da5747046746b6dc50821cfef90e
MD5 f56b5fc2ca3f671c1845b98376a3800e
BLAKE2b-256 88481aa7d2c2139929a4e84935a045c7cf30406c75b0b815dc3edb91131f9a8a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.9-cp312-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 9dcfce818a151107e15e30971823b13775e78e450346779c48ceb517e236adbb
MD5 96368cb1d36f669f32ef59d403c75669
BLAKE2b-256 f85ea700ece995fd74efc247e10454aa4a1cc6eaa6f279ebd57994c8e441a16a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.9-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 440b5c41422e9b9d74ce2887fbe75493e042d092a8aa40889a0718f2a838c1ed
MD5 4909ea2a638dd00eeb6ff5e5fe21b3f8
BLAKE2b-256 acfd137325db1e0c21f2074338c4c0bbaa4c39521a7697ac6910557f65da5116

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.9-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 587397e27e0af4ddbc0b5409e3b48f9f95f7c449e8daa3b3844da6c6ebdaf387
MD5 8b189037d8c27495818fad3d0ed5a33e
BLAKE2b-256 be6ba7e29362355e286564c1ed7f68ea17429c90d4007218035a8b853a6faeb8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.9-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b2989019a3d6987457d1de71c9a9d7b6abc513482b780a9c3da12c76b68e4845
MD5 d5bc0a83c07383f46e852635afe5c95a
BLAKE2b-256 42dd5ca83241a3bbc0f02998663545ab86eb039743ed03f3a91eb24a5a4b5c54

See more details on using hashes here.

Provenance

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

File details

Details for the file pyhdb_rs-0.3.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1d3f48dccc83a4c41b1a1e63a5eaf1cb0b91a0a7346b694aace4b951b75f1497
MD5 958502b249cf4bb5dab984553e7935a5
BLAKE2b-256 d4c9c0f97447b0a94b6f2078d3b4186539973b006bf69937404091a968020234

See more details on using hashes here.

Provenance

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

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