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.6.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.6-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.6-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl (3.2 MB view details)

Uploaded PyPymusllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.14tmusllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.13tmusllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.12+Windows x86-64

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

Uploaded CPython 3.12+macOS 11.0+ ARM64

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

File metadata

  • Download URL: pyhdb_rs-0.3.6.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.6.tar.gz
Algorithm Hash digest
SHA256 34e9390886b72e57cbe441a9fa889b24f4b3b7049c853d928ddddd9b9784fcad
MD5 ed4947b239fa9315797ee038026ea82b
BLAKE2b-256 d89a100c844ae6b1f975055a66f6229a83d9f266ae6a493c43dfbe7ffbc55832

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.6-pp311-pypy311_pp73-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2ee85084d9edf807d28dbd36ea54de63307886217cd41a943382da6992ef5a98
MD5 e318e960bfc5e6b4cdf5e79788d78a08
BLAKE2b-256 258bde817cc3504b765a42b988bc9019ac1c31e285793913abb26f8fe45380ef

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.6-pp311-pypy311_pp73-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 bc65f13bb2c27294da2eb583fe0188b9e75e4a5e3aa290320c7d5fe8059db0a4
MD5 67f40eb42a1553e76737308a5fc87689
BLAKE2b-256 c518f0cc2734a853ec654224905daa22c71ce4c13de600f85fe833c03f4298bd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.6-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c4d2fd237fafea657b7adca0245fb6b101bf34d90e89d5ec79403616996f7b7f
MD5 2df74aea3cfbc9ba098596dfcc894351
BLAKE2b-256 7aedb8d388f2946ece21c906d43c3c6fa2d5481e60560c9dc0de1641bc7b8847

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.6-cp314-cp314t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 dd0effec725afa13f48b55bf3b39b8d1f59118e5a4085c55d260465a1c646376
MD5 f03e5777e82713e4cd6fdde0b68df363
BLAKE2b-256 91b3f3e31619adf1d4cd225e84c87051a2118b445484df89402e15967af39cd6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.6-cp313-cp313t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 78594e842aec33ecc7b926a71be558d96ae72779cc82d4e72eee676cb7134d25
MD5 2794b6dff010b6f92c703d8823fc680b
BLAKE2b-256 e0c733a5a2d0fce28da72ac960083c68b545c24d0d8572f4fb20eee389f02ec1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.6-cp313-cp313t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 21eef503fbd30b3870e98e536532a71dca91f7030267d3a16a89f26f5bf50116
MD5 81f06293cd2bdf376cec7b5396e89d18
BLAKE2b-256 7d5156496540e205baf76351ff58f42d1b3227bd98ca09363952331695c42f15

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyhdb_rs-0.3.6-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.6-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1b9ad09f861fd55130eaf1f9d05616aeeb3677bfaea858fed28cdd2668bc4d8e
MD5 78ae800ae9d37a7ed8d6747662ced9a2
BLAKE2b-256 c3fc99c08eed71c52f84fa40b1cf64dcf0bb95c50e8c02b14ce84b52eb8e0e0d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.6-cp312-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fde60312cf516c875755ed55ab0030a3994f6b67616eb12a196a8daeac3ed9b9
MD5 8f6083bb99a2e61d8ebb67a6c7b2844f
BLAKE2b-256 346cf793fb0729aca7c158e84737f0b7b322207c41acd62eb94c366335c2209e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.6-cp312-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 ed98e04dcb39bab090f7e0dd014fc8fc89bab7dc1d226b0be1a2c4beb25c3cad
MD5 9666b2b2cec20342f01331e241648e8f
BLAKE2b-256 eb7130017f002cdc1f03ba38e49c0036ef91e704f8c31bcd0db03ba0a3e4c41a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.6-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 218cf09e28bef381e36202c9c41094b735878dfa845297b20d6a0121a7a48bec
MD5 13626be0f3f9376a4b55469572a1e9a1
BLAKE2b-256 7d4ba9ba6d3c81e90813634e04850f785a3c4d68687ea4d02c5d873456eadf72

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.6-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 65df0e26e1fe9565527a49bfe635b6bdedf00dcfcc08f6067f40a3eb1b64342f
MD5 0a12ad02071263168c200866936c41a1
BLAKE2b-256 b6c17ffebc561ede819c1d509c8809363efe206261b794b46cfbd237ae244088

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.6-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4aca341aee1fc641fd27ecf377bb239c40843fab26c358dcb8bc8cf2dfe61a3d
MD5 63a7a4113d2c4bf11f59ec17aefd15b0
BLAKE2b-256 1f051f42648fb3f456743e2d1aa9aaa30457b13bbf90786025f94c9c261efe7c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyhdb_rs-0.3.6-cp312-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 6762e048c4dcf27ccf6a4f434517ab55e65a005b7b52e0f4fa4cc38139a09895
MD5 6da56aed5b4cf42ecf77c27018ddad03
BLAKE2b-256 8fa3c12029130efdb63b0ffa7f0331d32195da4c81f22024c96910e1578a90db

See more details on using hashes here.

Provenance

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