Skip to main content

SAP HANA Python Client

Project description


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 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(
cursor = conn.cursor()

Execute a single statement that does not return a result set:


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

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

Loop over the rows of the result set.

sql = 'SELECT * FROM T1'
cursor = conn.cursor()
for row in cursor:


See the SAP HANA Client Interface Programming Reference for details about developing with the SAP HANA Python Client.


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.


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:

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release. See tutorial on generating distribution archives.

Built Distributions

hdbcli-2.14.23-cp310-cp310-win_amd64.whl (3.4 MB view hashes)

Uploaded cp310

hdbcli-2.14.23-cp310-cp310-win32.whl (3.1 MB view hashes)

Uploaded cp310

hdbcli-2.14.23-cp39-cp39-win_amd64.whl (3.4 MB view hashes)

Uploaded cp39

hdbcli-2.14.23-cp39-cp39-win32.whl (3.1 MB view hashes)

Uploaded cp39

hdbcli-2.14.23-cp38-cp38m-win_amd64.whl (3.4 MB view hashes)

Uploaded cp38

hdbcli-2.14.23-cp38-cp38m-win32.whl (3.1 MB view hashes)

Uploaded cp38

hdbcli-2.14.23-cp38-cp38-win_amd64.whl (3.4 MB view hashes)

Uploaded cp38

hdbcli-2.14.23-cp38-cp38-win32.whl (3.1 MB view hashes)

Uploaded cp38

hdbcli-2.14.23-cp37-cp37m-win_amd64.whl (3.4 MB view hashes)

Uploaded cp37

hdbcli-2.14.23-cp36-cp36m-win_amd64.whl (3.4 MB view hashes)

Uploaded cp36

hdbcli-2.14.23-cp35-cp35m-win_amd64.whl (3.4 MB view hashes)

Uploaded cp35

hdbcli-2.14.23-cp27-cp27m-win_amd64.whl (3.4 MB view hashes)

Uploaded cp27

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page