pyhdb-rs
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_rsfor 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 withfor 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.
Metadata
Release files for pyhdb-rs 0.3.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyhdb_rs-0.3.14.tar.gz | 186.7 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pyhdb_rs-0.3.14-cp312-abi3-win_amd64.whl | CPython 3.12 | abi3 | Windows x86-64 | Details |
| pyhdb_rs-0.3.14-cp312-abi3-musllinux_1_2_x86_64.whl | CPython 3.12 | abi3 | Linux musl 1.2+ x86-64 | Details |
| pyhdb_rs-0.3.14-cp312-abi3-musllinux_1_2_aarch64.whl | CPython 3.12 | abi3 | Linux musl 1.2+ ARM64 | Details |
| pyhdb_rs-0.3.14-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.12 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| pyhdb_rs-0.3.14-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.12 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| pyhdb_rs-0.3.14-cp312-abi3-macosx_11_0_arm64.whl | CPython 3.12 | abi3 | macOS 11.0+ ARM64 | Details |
| pyhdb_rs-0.3.14-cp312-abi3-macosx_10_12_x86_64.whl | CPython 3.12 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 24.8 MB
Release files / pyhdb_rs-0.3.14.tar.gz
| Download URL | pyhdb_rs-0.3.14.tar.gz |
|---|---|
| Size | 186.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
741bef0f2a5a24d5788019fb0f5fa8c412aadaec471b6068bba70c82b325421a
|
|
BLAKE2b-256 checksum How to use checksums |
f14adc1eebbddaeb2b89ddf3cb7b766a48fc332a7fad6b89e71f92640f1e84f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency logRelease files / pyhdb_rs-0.3.14-cp312-abi3-win_amd64.whl
| Download URL | pyhdb_rs-0.3.14-cp312-abi3-win_amd64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.12 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ae5854b96bc653837f0f9c8342968feb323b5ce9da4f3c7f939cbd7bb33124df
|
|
BLAKE2b-256 checksum How to use checksums |
6f6abb5ccd8ae5a2a9504aa10fef7896e110a7c4d3ae0ffd791ad9db718f421c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency logRelease files / pyhdb_rs-0.3.14-cp312-abi3-musllinux_1_2_x86_64.whl
| Download URL | pyhdb_rs-0.3.14-cp312-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 3.9 MB |
| Tags | CPython 3.12 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
4c79e6f9b10a0e2ae4075323a0ab2a3b357d324fb7ba22bcfc6151e23fa240b5
|
|
BLAKE2b-256 checksum How to use checksums |
d72a07ded602d3e99116c256d5946df6bff7ccab3f768b375339bd79515d4335
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency logRelease files / pyhdb_rs-0.3.14-cp312-abi3-musllinux_1_2_aarch64.whl
| Download URL | pyhdb_rs-0.3.14-cp312-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.12 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
f6fdfadc61da631d9055419e38404597fa21ab5228bb9bc35a462e9888e717f2
|
|
BLAKE2b-256 checksum How to use checksums |
d872842c102be986f6a99174394a50012114483b2d0bfa0eefa03da728816d0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency logRelease files / pyhdb_rs-0.3.14-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | pyhdb_rs-0.3.14-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
847f8626a97cd380973ef6e8e46dc39a768295d1fe98573a5624ab0f3f7278c6
|
|
BLAKE2b-256 checksum How to use checksums |
47b100f0831e93ccdaccd10216a40f02f6649f560999c0e3ba52f94fef9c8693
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency logRelease files / pyhdb_rs-0.3.14-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | pyhdb_rs-0.3.14-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 3.5 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
7ae0ebfa2f2e434c95c95d8132b4e9afdd964c2dacb1f93538e562fabf601d4e
|
|
BLAKE2b-256 checksum How to use checksums |
c22b9b21bf75f53d35740fa38399368b049cdfed74ea95c96efa098fc7186869
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency logRelease files / pyhdb_rs-0.3.14-cp312-abi3-macosx_11_0_arm64.whl
| Download URL | pyhdb_rs-0.3.14-cp312-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.1 MB |
| Tags | CPython 3.12 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
af880a0301974a9bfd75ca11afc50bf278a5c8ebe97cc101f54d9bf66253dd98
|
|
BLAKE2b-256 checksum How to use checksums |
3df8fe132b8e780f8dbaffff5232cb76190d02a4b657c9b57de22f82d70bb410
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency logRelease files / pyhdb_rs-0.3.14-cp312-abi3-macosx_10_12_x86_64.whl
| Download URL | pyhdb_rs-0.3.14-cp312-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.12 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
83ab97ab57a8b32aac4821de8d924702d49fa8f61eeb4a7351fca40bcd78997c
|
|
BLAKE2b-256 checksum How to use checksums |
cebb0cef827c1cc99733919e9e7027e305b9439cfe282c1bdd44f9879a93f304
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.
Transparency log