Skip to main content

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

Project description

pyhdb-rs

PyPI Python 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.1.tar.gz (138.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.1-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.1-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl (3.1 MB view details)

Uploaded PyPymusllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.1-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.1-cp314-cp314t-musllinux_1_2_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.1-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.1-cp313-cp313t-musllinux_1_2_aarch64.whl (3.1 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.12+Windows x86-64

pyhdb_rs-0.3.1-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.1-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.1-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.1-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.1-cp312-abi3-macosx_11_0_arm64.whl (2.6 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

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

File metadata

  • Download URL: pyhdb_rs-0.3.1.tar.gz
  • Upload date:
  • Size: 138.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.1.tar.gz
Algorithm Hash digest
SHA256 3a08d2cb25be87eab340cfa22884d738208ccf36c63ec842fa79d83022138f0d
MD5 dd691ffa2f0f87978ac6f4606e8c1c93
BLAKE2b-256 212f46fb896e83471028b6a117e6f2cf7cbb2e4f27efe049d979a76b66142132

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.1-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 81a0af63252ae99216bef6ec702bf27b9720db140c47cce49fdc0f80a7f78538
MD5 31ff389abb6697a40b1149ebbb152fcc
BLAKE2b-256 60b093ef61b831d2a9950e95f3998262937b4b6460742915618c690bab814038

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.1-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 b86ff8735d46dc794ff2ed3e8b7d58556a32f24ab1bc89f187d020a0de74afe2
MD5 226b51bc4b9505a4dc9d4cc756df2e3c
BLAKE2b-256 08fbda876e1139b9057d96ab806e3b2d2dbc2022a6c2d37d3508bb63b0bed988

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.1-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6351bde1c37d5f350a5257d862e0c861d145fdb86b22e7b8a19c77ae24d4328c
MD5 f43f0f5468ac72f769bfaebce5218d85
BLAKE2b-256 06d05f09aac5e63c6821da1c331654d9876d815ac18e205767c8ba0ba304ce32

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.1-cp314-cp314t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 fb772248ff73f68ccc7602489bc31ad0f5f8436a4174fef13ee47daae5c34ff7
MD5 d2fb94e9339996502db6113600acbde4
BLAKE2b-256 eb4f0911d0c9ca5c0103b4d1a35d2438a6f2cbc99679b6ab0bcb3f830fb461a1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.1-cp313-cp313t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 39a938fbfc6d4dbb3b634c8067394959539bea97448c85e1ca65a6d22d874e6c
MD5 e53599708340a5ba882881dbd65f55af
BLAKE2b-256 6d1fe6ea8869a99bcbb6658d7f612ffb4fec74884fe7551c6d95c4f1f7aba24f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.1-cp313-cp313t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 4c045c3466725592b1be8a5b41eadefa5b51f3aac3890198c777ecd93d257f8e
MD5 bfcc2c9aec3b734dcb0a33bd6698aa34
BLAKE2b-256 726ec7682009a5d7f9f5136d7d6ca40bb13c624adceb016b3bcf9d613a5f9f48

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyhdb_rs-0.3.1-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.1-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 4b18385909223b410aa541d5958c233d1ceb01bf75df06611e3ad7ef2c418ede
MD5 7a14109e3918ea641354efcac546649b
BLAKE2b-256 6a4b583312283f2741faade037c0c130d1d748b287020900489a1a477928111d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.1-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ed0a368a9de6e9f0a9425a1f40de00feb2ab66df58d147e4003c74fa203fb2c0
MD5 340f14af2616385100afd62ea16335aa
BLAKE2b-256 21ef0b5dcf0fe39a54221fdb4fa0ef565fb5172b90a732606ba310e69a0a4fa3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.1-cp312-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 e84d7fe06f1602346e2b5153e943e857af316be4e97f0b96114b4b8760badd05
MD5 e5ca5a792ca51dcb6c7895b80f4b2320
BLAKE2b-256 350c2c5090451793c592d10a3e6e1f4a41120da9f7c3e4e3ffd728b4e376535b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6e89e05cd732077af382c8a23e8e15efde4fb1dccd2052422068e32b9e203f04
MD5 5cb95e720740e85bd5eda280029f324d
BLAKE2b-256 bee0955b62909ecc5fdcb5052a095750e3a2755caca05f165f732c1c3ed0228c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1ed9b6a87f9b551a0e87d9d5b52c940de506eecb70462d78f8c0521562d388ba
MD5 721bc67810f7c50e487dd0c71c89c9fb
BLAKE2b-256 d975582f3825c2ea79ce55c2da795f805790325d243e53c6e6eab2c6c1310faf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.1-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d5a406e45a46e699a421c17bb21ce5cff7519ded128207ac29802532b2364eb3
MD5 84e622f9000f1c44108afc508b98dc7b
BLAKE2b-256 1645e07d19fb9226869721bca7d137abc96b428e9904b49ed748ead42ce4c832

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.1-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 56dc2eb63fd6aeb4d3cd90b4be172e6a9100ca1248e6e61ce5e5263fc6b883c7
MD5 1c6fb0e0c56b540f6df30d60af46ae20
BLAKE2b-256 aac8798a979e098b59de50b3474f83799033df9c88b6ca9ac624bb079df3ad53

See more details on using hashes here.

Provenance

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