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.2.tar.gz (159.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.2-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl (3.3 MB view details)

Uploaded PyPymusllinux: musl 1.2+ x86-64

pyhdb_rs-0.3.2-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl (3.1 MB view details)

Uploaded PyPymusllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.2-cp314-cp314t-musllinux_1_2_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

pyhdb_rs-0.3.2-cp314-cp314t-musllinux_1_2_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.2-cp313-cp313t-musllinux_1_2_x86_64.whl (3.3 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ x86-64

pyhdb_rs-0.3.2-cp313-cp313t-musllinux_1_2_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.2-cp312-abi3-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.12+Windows x86-64

pyhdb_rs-0.3.2-cp312-abi3-musllinux_1_2_x86_64.whl (3.3 MB view details)

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

pyhdb_rs-0.3.2-cp312-abi3-musllinux_1_2_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.12+musllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.2-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

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

pyhdb_rs-0.3.2-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.9 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

pyhdb_rs-0.3.2-cp312-abi3-macosx_11_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

pyhdb_rs-0.3.2-cp312-abi3-macosx_10_12_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.12+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: pyhdb_rs-0.3.2.tar.gz
  • Upload date:
  • Size: 159.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.2.tar.gz
Algorithm Hash digest
SHA256 2b511c860aa2e0eae3031b6723f674146bcc878d4364ce9d6b57f5c95af67b55
MD5 b699151003d28de1c6a413265388d155
BLAKE2b-256 aae0520b59b2cec09fe4bd21d3785c989d1071b43f7cb72848fd1ad97212c92c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.2-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6fa41a721397fd86a5d9e93960b3932796d871b750bdceb25f9c9f9187118672
MD5 1239edc2172f5427a2d5193da66159f9
BLAKE2b-256 62ff3211893aec616f3291c87aa7e3e2896f4645d9a4e13def20f642db3fa028

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.2-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 f3d377cbdcc3ec4539a79489ca2537938cc50c3dad9642f508c1ec6fc15b6d49
MD5 00a9362799c206149f2a889a44d40529
BLAKE2b-256 6cc45329b9524748be41f1df3bc1cf76dc2f502ea770030d11db175278d0ccf5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.2-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a1ab6c27892fc9076d7f78fb56fbd7c68fe4a46f958116a1771a55c1b8bdee78
MD5 b66faee2ff42278bd7f58e20ea76bc9b
BLAKE2b-256 20e051e565d8373a3b6de0ec38d0c1c86103e81681f3e0a565d9b7f11446ae23

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.2-cp314-cp314t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 49b5960d28b7eed8f9bc908e53ec10dfcc432d53d46022dae5881890be209d87
MD5 59ba14a9546be8eced382989656163fc
BLAKE2b-256 0c18a0ecc6523d13e2a9a8d84c55cc9b1c00647b34853ef6163c7c86d43557ba

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.2-cp313-cp313t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 158b9b9e56b338c6eb25147fa0b93cf1b56144517a8c0da1f7a9d7a30d2812e5
MD5 43dc7702d8b082e95ba50d2bb18a70a4
BLAKE2b-256 a53f2f788fa974419896a88df6066aad6d0d7d12c3c1ece5e89c5d08a1711264

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.2-cp313-cp313t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 8be7e0dd28c2d81a496a6f100a1bd9834483d9259ef128809a02fcf9f011627b
MD5 c13a097dcfc279e81cb42dc4b12cbaa7
BLAKE2b-256 d5c0a8857748a6ddbf1c301e24b2643e68d9e9a1ac44124eb4a8e2f500acee3c

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyhdb_rs-0.3.2-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.8 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.2-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6a0821f2e040af701923d24d6242042af6ff91730cd54f8e6aa2fa55637c54d7
MD5 881b2a2deb227e6cefdf7d2eb53f90a2
BLAKE2b-256 8b49ccf2f212d5cb4f62fb08b4fc8c6c9faa3e05b59e9663c4614e2f53a2ee51

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.2-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 82ce0ba8e1d3f60d2e717a5283d396263d1905ed19e64f121d021a72cf8dc169
MD5 8a69e75cc99f7efdda0bbf2b910faca9
BLAKE2b-256 9564074c4275398cf0ae410d6928c0c91090e9be19604981e91379f75d073e97

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.2-cp312-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 23956e600bf91a5028ae35743672ebd3281995a19f63f022e46d2464c5e58b54
MD5 e1350261797224a7bfffe28caa3bd3c8
BLAKE2b-256 5db0f3be2a466ae1677aa1ade7e552b9c38d4b8a67eab49ad25b74784601ed7a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.2-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0fcb8d0ec8459e36a0791b4ba52b793d6dca13b727f1854b85de8d683c1aa80e
MD5 1f7c8162bdbe65716fcc2b60a1fb159d
BLAKE2b-256 57a198c8f031e42d83712be2be67d82700134410ba37e89fd43e7a3292ba74b5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.2-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4e3bd89f714ea52964d9e1df3642a8235463b11b1c4890b643d65b775047da6b
MD5 57736357c3a85215764ddb7b85502c6c
BLAKE2b-256 ffeaf48bc4322b68a327638cca1669bc4d816a22b88f8cacd6ef049f1448d30e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.2-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c6f972b1578f821001b846100733cb2f4a344cec9571f40494521947d5140ad8
MD5 2390839185eb339a7a30052c4b6bd1c0
BLAKE2b-256 03962308eb79ea95cceb668610b5bcc0cf8be64c239be6188d22b4c2fdb41fa7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.2-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b138fef4dddd8f31dc4e2a4721f73f902b1881da7dd663972a7eb8bbf89bf108
MD5 807af9843c2b8ee462d801705cb030c5
BLAKE2b-256 270eac480136194eb0ba297bbcdf92173ddfabf9b40ed4a536c0e8b517682fb6

See more details on using hashes here.

Provenance

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