SAP HANA Python Client
Introduction
The Python Database API Specification v2.0 (PEP 249) defines a set of methods that provides a consistent database interface independent of the actual database being used. The Python extension module for SAP HANA implements PEP 249. Once you install the module, you can access and change the information in SAP HANA databases from Python.
In PEP 249, autocommit is turned off by default. In the SAP HANA Python driver, autocommit is turned on by default.
For information, see: PEP 249 – Python Database API Specification v2.0
Getting Started
Install via pip install hdbcli or install manually via the HANA Client Install
Quick Start
For HANA Cloud databases, the port number is 443 and encryption is always enabled by default
For HANA tenant databases, use the port number 3**NN**13 (where NN is the SAP instance number - e.g. 30013).
For HANA system databases in a multitenant system, the port number is 3**NN**13.
For HANA single-tenant databases, the port number is 3**NN**15.
from hdbcli import dbapi
conn = dbapi.connect(
address="<hostname>",
port=3<NN>MM,
user="<username>",
password="<password>"
)
cursor = conn.cursor()
Execute a single statement that does not return a result set:
cursor.execute("CREATE TABLE T1 (ID INTEGER PRIMARY KEY, C2 VARCHAR(255))")
cursor.close()
Use question mark parameter binding to insert values into the T1 table created above. The parameter values are supplied as a Python sequence and can be literal values or variable names. This example uses literal values:
sql = 'INSERT INTO T1 (ID, C2) VALUES (?, ?)' cursor = conn.cursor() cursor.execute(sql, (1, 'hello')) # returns True cursor.execute(sql, (2, 'hello again')) # returns True cursor.close()
Use named parameter binding to insert values into the T1 table. The values are supplied as a Python dictionary, and this example uses variable names.
sql = 'INSERT INTO T1 (ID, C2) VALUES (:id, :c2)'
cursor = conn.cursor()
id = 3
c2 = "goodbye"
cursor.execute(sql, {"id": id, "c2": c2})
# returns True
cursor.close()
Loop over the rows of the result set.
sql = 'SELECT * FROM T1'
cursor = conn.cursor()
cursor.execute(sql)
for row in cursor:
print(row)
Help
See the SAP HANA Client Interface Programming Reference for details about developing with the SAP HANA Python Client.
Community
SAP Community provides a forum where you can ask and answer questions, and comment and vote on the questions of others and their answers.
See SAP HANA Community Questions for details.
Limitations of 32-bit Windows driver
The maximum length of a LOB column for the 32-bit Python driver on Windows is 2147483647. The maximum rowcount that can be returned for the 32-bit Python driver on Windows is 2147483647.
License
The HANA Python Client is provided via the SAP Developer License Agreement.
By using this software, you agree that the following text is incorporated into the terms of the Developer Agreement:
If you are an existing SAP customer for On Premise software, your use of this current software is also covered by the terms of your software license agreement with SAP, including the Use Rights, the current version of which can be found at: https://www.sap.com/about/agreements/product-use-and-support-terms.html?tag=agreements:product-use-support-terms/on-premise-software/software-use-rights
Release files for hdbcli 2.30.27
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| hdbcli-2.30.27-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details |
| hdbcli-2.30.27-cp310-abi3-win32.whl | CPython 3.10 | abi3 | Windows x86-32 | Details |
| hdbcli-2.30.27-cp310-abi3-musllinux_1_2_x86_64.whl | CPython 3.10 | abi3 | Linux musl 1.2+ x86-64 | Details |
| hdbcli-2.30.27-cp310-abi3-manylinux2014_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| hdbcli-2.30.27-cp310-abi3-manylinux2014_ppc64le.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ PowerPC 64-le | Details |
| hdbcli-2.30.27-cp310-abi3-manylinux2014_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| hdbcli-2.30.27-cp310-abi3-macosx_13_0_x86_64.whl | CPython 3.10 | abi3 | macOS 13.0+ x86-64 | Details |
| hdbcli-2.30.27-cp310-abi3-macosx_13_0_arm64.whl | CPython 3.10 | abi3 | macOS 13.0+ ARM64 | Details |
Total release size: 42.0 MB
Release files / hdbcli-2.30.27-cp310-abi3-win_amd64.whl
| Download URL | hdbcli-2.30.27-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 3.8 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
99d30bf6ea7b43cc8acea76dd0bea0ae5344f7f49cddb8ca523ee2ae02db37e2
|
|
BLAKE2b-256 checksum How to use checksums |
3674fc82ee9a6f03965e2d5a743d988844853ff7fae489e07a504f90aaf20d83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.1
|
Release files / hdbcli-2.30.27-cp310-abi3-win32.whl
| Download URL | hdbcli-2.30.27-cp310-abi3-win32.whl |
|---|---|
| Size | 3.5 MB |
| Tags | CPython 3.10 Windows x86-32 abi3 |
|
SHA-256 checksum How to use checksums |
eb4b0b5afc71ac9719f4b6ad3d1c72c9fd34e6594aafd89bd738d7f4ad1ea453
|
|
BLAKE2b-256 checksum How to use checksums |
82b8be0de1c838851750088affd9fbe50de9a503681996514292444058e3ebdb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.1
|
Release files / hdbcli-2.30.27-cp310-abi3-musllinux_1_2_x86_64.whl
| Download URL | hdbcli-2.30.27-cp310-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 6.0 MB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
a353f219359a9eef0126731e398a7a3ae8f46e7263dda37f49e6af272dc776af
|
|
BLAKE2b-256 checksum How to use checksums |
b8997c45f65d0b62782376428a8e0d6455b234c3e3d354bc044196215bb30949
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.1
|
Release files / hdbcli-2.30.27-cp310-abi3-manylinux2014_x86_64.whl
| Download URL | hdbcli-2.30.27-cp310-abi3-manylinux2014_x86_64.whl |
|---|---|
| Size | 5.9 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
8dae4357c648b199e1a10bddd29c87a7d8a23d3b1899b1d9e70b0bd3274ceae9
|
|
BLAKE2b-256 checksum How to use checksums |
6689d9c10352b6fcef91f4c91981db3f419ba0c246d5962caca8f6305dd15896
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.1
|
Release files / hdbcli-2.30.27-cp310-abi3-manylinux2014_ppc64le.whl
| Download URL | hdbcli-2.30.27-cp310-abi3-manylinux2014_ppc64le.whl |
|---|---|
| Size | 6.2 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ PowerPC 64-le abi3 |
|
SHA-256 checksum How to use checksums |
62087ef27599c32ccf566ac96d225da263c53337b6a2dca6d207ca5e5f647b23
|
|
BLAKE2b-256 checksum How to use checksums |
f182fd1b0c197d0cc01cb455b224cecd5f86e3a322adea45ff8d5e6f59c3f9da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.1
|
Release files / hdbcli-2.30.27-cp310-abi3-manylinux2014_aarch64.whl
| Download URL | hdbcli-2.30.27-cp310-abi3-manylinux2014_aarch64.whl |
|---|---|
| Size | 5.6 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
4e5c835269ea7563454e91586b593dbb60bf2e27c8ee75fd185b88e64760cf47
|
|
BLAKE2b-256 checksum How to use checksums |
d09c8087545a343ba3bd0f655dd8cbc0684b4371fd82650b5db966642852a737
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.1
|
Release files / hdbcli-2.30.27-cp310-abi3-macosx_13_0_x86_64.whl
| Download URL | hdbcli-2.30.27-cp310-abi3-macosx_13_0_x86_64.whl |
|---|---|
| Size | 5.8 MB |
| Tags | CPython 3.10 abi3 macOS 13.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
c20d2cfb1c102dd204624e1edfb370245955b4d29794d4ec01625b8a820faa47
|
|
BLAKE2b-256 checksum How to use checksums |
f682b36d27b354890542bc89be1885b43c61ee9bc342a686a4e6bca72a0339f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.1
|
Release files / hdbcli-2.30.27-cp310-abi3-macosx_13_0_arm64.whl
| Download URL | hdbcli-2.30.27-cp310-abi3-macosx_13_0_arm64.whl |
|---|---|
| Size | 5.3 MB |
| Tags | CPython 3.10 abi3 macOS 13.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
2a95a20cba24a67955531c85c755bdf22b0dbd56c2dca28072de4e6bc71c8ad8
|
|
BLAKE2b-256 checksum How to use checksums |
0cba094197bc10e3b2f2bd22bf7069e1d8a5e9bf81f95fdd59f28a320361729f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.1
|