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

Uploaded PyPymusllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.3-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.3-cp314-cp314t-musllinux_1_2_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ ARM64

pyhdb_rs-0.3.3-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.3-cp313-cp313t-musllinux_1_2_aarch64.whl (3.2 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.12+Windows x86-64

pyhdb_rs-0.3.3-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.3-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.3-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.3-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.3-cp312-abi3-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

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

File metadata

  • Download URL: pyhdb_rs-0.3.3.tar.gz
  • Upload date:
  • Size: 183.5 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.3.tar.gz
Algorithm Hash digest
SHA256 d044802519496c2e3f4952d3da850990d10189820134fe2ccff956585e337a8e
MD5 34c81c3a9ee8da2d2026f9ae0170077a
BLAKE2b-256 0e0ec801f662561199120757a06a0ad36a76c258b423a6555a22bb211a0b282e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.3-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3f24a48258da5a34b05f8a45a640f292233a240a1460df7f8f1f4db642362572
MD5 520577db80263cab56821ee2cf5bc1e0
BLAKE2b-256 68f87e7456e2668a03f5055cb8dbe20e540e5b29f868e311a8eab6eda4c50e7c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.3-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 96f390fe30c2e18627e695938ee3b540874313629fd6cfda235264eb0c9a9a1a
MD5 950e9ee195c7a5b23fd27a5b7cf84c80
BLAKE2b-256 7d1d4f80baecf19dbb7de0921f090358fde26928f1dd40a7f8d7f64913780c6a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.3-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 cb4de794aead31a317322ec355a08d7f5291ed7f937cb516a76ab13722b4190f
MD5 8464fd92cec9f088ef9eb18151068d42
BLAKE2b-256 98cfee8cc0eaa2ac5388e5e9025359153bb9d5c14833ab6cd52434022e708a24

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.3-cp314-cp314t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 19ca0f098324195d3bf6afedd6f036b9a3ec268bfb761e6c1d99b825ab1cda73
MD5 ab6c4079392cfc8f3c8163db6f1eee9a
BLAKE2b-256 81b25e9cdbcfca47081d8cd584ddb6378396909ef1cfeb86913557ada14ebdcc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.3-cp313-cp313t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 acd5bd767bda522535562ea802cb9cb33dc9d45c52abe58aa11e787edee3c259
MD5 18eb1a87d7eb2fd2e09544f6dfb89db0
BLAKE2b-256 d4980a81a7e6012a89cb6b3db821f18db9fda7e346a4b3b1839bb8d504b28808

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.3-cp313-cp313t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 a0d1478a4ddbf4ad5a3ecde210883ebcbfa0cccad7763defd6fb9464afbfeb54
MD5 c2be9997d2e279c0f091cc2e1ebb90e4
BLAKE2b-256 a287a898e84211b0824b7ae0042228fc7f35a25879d1e125016cd3c77aa93175

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyhdb_rs-0.3.3-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.3-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 533190097790b827ede20467b0dc4072a06994b779e88a438142e364fcc1a513
MD5 f0fce2ab3212fa283441edf1acb14850
BLAKE2b-256 39eb5a252c1d78834f734b003544f7ec3d8836746568ed4ba6dc95ad1da638be

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.3-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b7afb2f39700a1033fc05b9ce390ae30f1afed2a47406cb4e15a241032366160
MD5 6ecf1b55a53b9e14a32457cb1bc04cf1
BLAKE2b-256 085bc2e924ef338cd397f85bb9adb329344891bfcdc2872781838b073a90fe25

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.3-cp312-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 5782d70bc4d4e86a58679d5752a68ee6d8eea7f32d3765feed36de485ccb0af5
MD5 dff14d5969c559eda00ce6fed58e51ea
BLAKE2b-256 373615ad9c897471b6dc4811c29322c20fdde1034bd2ed83c5f08848fda0424d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.3-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3cbd7caf169fc80fe0072093c5c8db04f617bd897ecaea3254489542f418853a
MD5 a4403cad69b382e4b78bc7b4fdaafd86
BLAKE2b-256 7e44a1a04c140dc493b94605336d3d5c0986a50e7d04fd19b97dac564c190eaa

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.3-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a7c63695df572a2c82a50c29a762425a6bc2ce264808dce8d0210fbceea2045b
MD5 057d1d2ec184217d6699d555e747d226
BLAKE2b-256 b9d703e87dea023cf1933d9017263b8f5092c3e1a7e966e207572bba30b26f99

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.3-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3c171eaa2853759a86e8e62b194d4788e0368b8c14b28e88404c2531d72f387e
MD5 23281c55ffc6b6322fbdbfc060002c79
BLAKE2b-256 d24efa6938cceeeb4abd1378c1fa92bbfc3c493f901a5a02ad9ac8607ba0448d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.3-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 334032e448382ad25d0a8cf9346680a874f3100bec5e1ec24c22c423b4239ad4
MD5 cc0b3e8f1c754055c62c30d88c03bf5f
BLAKE2b-256 43da578f90614b46a707423cf13cdbeb2cad1905bf701634bc345ee462191276

See more details on using hashes here.

Provenance

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