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

Uploaded PyPymusllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.14tmusllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.13tmusllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.12+Windows x86-64

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

Uploaded CPython 3.12+macOS 11.0+ ARM64

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

File metadata

  • Download URL: pyhdb_rs-0.3.7.tar.gz
  • Upload date:
  • Size: 186.6 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.7.tar.gz
Algorithm Hash digest
SHA256 b00d51b3d5689e4672c409f515a2dcef9d9df43f9d80992664ea0c3b74bae368
MD5 8e0a63e57be21d6247c44b4fb5b0304a
BLAKE2b-256 c78cae8480d98ea42bf52eab5bf7ee68370b3ab3130b24f5a5bb48f35ed2494f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.7-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2e506cb64c573c502c7ccc04b7db36e7888e7ad4a11482804bb791fac6d9482b
MD5 6dd81bd2bca2f37e9ed0c1fbbe3af593
BLAKE2b-256 059c6032c57061f221dfdd82a50a60d8aceed3b2efb6e138178e9dc128fd3602

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.7-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 1feacc8bdc5b4bcd4840730679bae103cbe201825f9243a8cd8eae269a627993
MD5 1b6f77e84dee873df863b40f82f97959
BLAKE2b-256 6d86a10f67d6258002de12d7879fc0b1309e2d2ef350b103527d4232cabae8e1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.7-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1185f18a0c627bd0ecbff3085abb56ee2fb6bcfced6010bebce94bb6424a5efb
MD5 b273ada1fe38722c7f00bff41c6712ad
BLAKE2b-256 7da9581449d246db10605a7d8bfe73b9e593d656ab38f7d81f40c4b40af51834

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.7-cp314-cp314t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 d48e528e0ea6126d0a9c35f67188fd8107751960a75d3fc41f4d9d80ab9b1e84
MD5 9810c04ef163244d64b3163cedde6ed6
BLAKE2b-256 7efacd6dda6f471be8e4896f0b69e19977bff579915bf9522897451f4774360b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.7-cp313-cp313t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3a54bfae9d30d703f6f6082a28b706a01ac32fa0f204e68bb8eb8ca936ed1a95
MD5 47a8ffee12fa63a894a29056d92604b7
BLAKE2b-256 ae96cc14f89fa86880c7d1f20e24b4de0a7ee5edfe57c3728a76033b58c2b3b3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.7-cp313-cp313t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 9bbf9f3e995f47c62cc8e5a1af8cd19109e283e6bd95661031b8716f1c3b341b
MD5 81f28c5953b25cade4896b24905fabb9
BLAKE2b-256 19a7390c17ed077b79e8e24a537bab9bab2c7707cd8839a640cf7db78966b3c8

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyhdb_rs-0.3.7-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.7-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 911568981c3e814c6457a0884e4f6572336defd7dd24bbdf13322429204e4f72
MD5 ce440ee4f5bb339e6e46a2123e152e21
BLAKE2b-256 16a346b8aa3a0cdc4af293596ab2d1dca040b9410c14e987ecc68e15724eb637

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.7-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d723e8330c738db9dcb20f64650511810f0a64f3c23501073698571c5b9450a8
MD5 3819b0dd1dd5380a107ed59ded1474a4
BLAKE2b-256 8cb600020591c95909de0b8041a9ff74b38b6ed1debdb2ee21a4538ecd03f2e9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.7-cp312-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 e38ba749d00eb9b13fcc8fce91d014320fc580b212e35d6b07e884ddfa60cf74
MD5 abd5a62f1c810760ea9acdbab188537d
BLAKE2b-256 8ac21b6e4f509b5d3831d7d36b2ccaf41d9c49424bdfd2241ccd882f316e9bc9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.7-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c0554a1caf262fa6f15371650c5cbe151d8291f1835e5626a8a1bad41e04b9af
MD5 6895a4021021ffcfd9df7f65fb97111a
BLAKE2b-256 da5d8f108340dc5e520264bffbe14c6106cdc933cce643ffa3e25a687c20e1ef

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.7-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6217b2ae299963a0d835e308b1bda89ae418e9163aa16873e6a3e01331365745
MD5 f2d773ccdc9d9100eebd5f2ee8722e6c
BLAKE2b-256 07d3a5ad2eb4982869807fc8a9342d5579340895f99e402fb73ef580e58144ca

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.7-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 96495bd70741aa18bd9aabcb94fa898f56b602598e4066f47eb543b7729ce6aa
MD5 f97cdbcccdaebc434c785d4b0691f897
BLAKE2b-256 fb9fa9405a2752a34ea86ead7c35e61eba8d28fcf3b1c0a0f4255563474a02ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhdb_rs-0.3.7-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.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyhdb_rs-0.3.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2ed69ccbf6860a8bc8ce93eee13b36b7d7e5ec20bcede3eff85d3d0fb0e33bee
MD5 1c0ba6be641421f533334ea4c6cb4c24
BLAKE2b-256 3252f4639250c75244b0bdab9aa5364a2063178a71f644ead0f75901890b9a76

See more details on using hashes here.

Provenance

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