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.4.tar.gz (185.0 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.4-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl (3.4 MB view details)

Uploaded PyPymusllinux: musl 1.2+ x86-64

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

Uploaded PyPymusllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.4-cp314-cp314t-musllinux_1_2_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

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

Uploaded CPython 3.14tmusllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.4-cp313-cp313t-musllinux_1_2_x86_64.whl (3.4 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ x86-64

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

Uploaded CPython 3.13tmusllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.4-cp312-abi3-win_amd64.whl (2.9 MB view details)

Uploaded CPython 3.12+Windows x86-64

pyhdb_rs-0.3.4-cp312-abi3-musllinux_1_2_x86_64.whl (3.4 MB view details)

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

pyhdb_rs-0.3.4-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.4-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.4-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.0 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.12+macOS 11.0+ ARM64

pyhdb_rs-0.3.4-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.4.tar.gz.

File metadata

  • Download URL: pyhdb_rs-0.3.4.tar.gz
  • Upload date:
  • Size: 185.0 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.4.tar.gz
Algorithm Hash digest
SHA256 bc766a48ed12d67d592960ad83459d25bd45194080d9d5127cd2072763f57d1a
MD5 9ca3a8d05c566dadac5330394d6d4ce8
BLAKE2b-256 c728d668e2e7b2d2683f2a0bd80552ffe599771c64467ae96aaf50228eb86ae5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.4-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e504aeb3e2c88f26e028483d0d7ebba4619859f7eb1b0daf189c5f50c11fc187
MD5 c9a486c83fdbe70a1742fa3604a7468d
BLAKE2b-256 d944667418ba3f7e0441ff24f9541815cc1e62eda479c5dee2f76b08ef5f3859

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.4-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 55c722399222bd1ae58922479e1adfdf6a5d3f6887868cd47fde9e5641e20195
MD5 12f0f91ce82abbc762d7209aa5bb81aa
BLAKE2b-256 9f3964dd9e5ef90f5b57b4fc64df513ffb249926b75fb771a3e86c062e0b0469

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.4-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b0e5b78d36e6b8169543cdd3bc3c87cf2c09318383ca215e1e00af3d423bf915
MD5 9bb67c255a6a974485fc368bdbe77798
BLAKE2b-256 3c7bcd5085e36e1858f0081348ffb9d500a3097d83be766435f6ae9ed23ffd82

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.4-cp314-cp314t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 5b9fad20dcef980b09239442ea35ecfb410abb78b0c0d15b60b9c7a628490993
MD5 f6b7714f0408307c15f961f72bbf9d7a
BLAKE2b-256 c53384b8421bd9a14672603e4aee711a6d41fd78eed779f8b4a62ee8774c98ed

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.4-cp313-cp313t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 de944e65ab45d6052243aebf051976cbae7d5d43e4ba8981cfe8d7c7b49f2455
MD5 4fd77aab6e04d0602c6392c955736d8e
BLAKE2b-256 2da8263f76d0543b94f310717615b0825f38f17a6d7cfd1a974b8d9edad8cc31

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.4-cp313-cp313t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 a777243c4cd2db644ad32f089ddf6d985e61bc74585b75c2f6cf37591d8bc68f
MD5 dc49cf2e189962038897c0010c6ca79c
BLAKE2b-256 2696286f13db6128cc4b2c148a4d72e7bf0313543c96c7fb976b80ee03098b5a

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyhdb_rs-0.3.4-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.9 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.4-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 247b683c0b35c76c3d64ac46b26e79260250bf0483ffb335f22b0b48b009d1e9
MD5 45e93caa6cb759206054435461688501
BLAKE2b-256 d9d8a7bca34215cb78251d2e301c0fa6283b522d93d244252ecf2fea6617fe37

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.4-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a6044ac5379934ceb4f173c56be7098642e4ada019dce1cae5c63e86fd126f29
MD5 31babf5338a21c8757c1773ef0bbe28d
BLAKE2b-256 fba20ed45336ad00129541d637b13abf2dec39bf5e36c97e23ced7d362c431e0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.4-cp312-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 92c21e970734ab174b65a71aaf8df38593238abf95096ddc3f2c3cc6e08ec80b
MD5 88d8ea992b5f51b6082c33636aa12114
BLAKE2b-256 99333d1f777c63417198e6c5bc11e2a2fd007dc91dbbe54a33e0c4c7d8ca858c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.4-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c51c7f8654a9ab377038b49984ad0d9b797024c8335dadfd235b2df4192faa09
MD5 be2e362f0f2d7e81d56ea85063fc1f82
BLAKE2b-256 a7c6fd75e029270348f5348d2177ed39e8138c505ef64448e969d2a1e91fb411

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.4-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cc7e0556c00428f0b84e06ac212fda9dea1ed257670d6c03c3c783deb2c5c1d6
MD5 faad2cfed77bc17ce7e9132350617150
BLAKE2b-256 e088b3c74714aeac5b7ed818fb704ede367fb4bea5db018c75101a9d92b408b1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.4-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 05133619b5850965facd07f46708ab422867a28895df230e6e80065aae26a1f8
MD5 08c238f6d650714427cc823bbaf26bc3
BLAKE2b-256 11a7be42fcb898175c5bfe54733ec21f8370d8ee787eeafe73099612d820c571

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.4-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 217630c0bf90944589b49946c5435edd0e8d19c4e8b1c0eed75aee272c2b43d3
MD5 e405971b85d069c5165cf913e65d8566
BLAKE2b-256 3e2ee206be62b5601b07c9b11e5ab7487babb456c919652b72d860baf3fb7bbe

See more details on using hashes here.

Provenance

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