Skip to main content

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

Metadata

Release files for hdbcli 2.24.21

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for hdbcli 2.24.21
File
hdbcli-2.24.21-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details
hdbcli-2.24.21-cp36-abi3-win_amd64.whl CPython 3.6 abi3 Windows x86-64 Details
hdbcli-2.24.21-cp36-abi3-win32.whl CPython 3.6 abi3 Windows x86-32 Details
hdbcli-2.24.21-cp36-abi3-manylinux2014_aarch64.whl CPython 3.6 abi3 Linux glibc 2.17+ ARM64 Details
hdbcli-2.24.21-cp34-abi3-manylinux2014_ppc64le.whl CPython 3.4 abi3 Linux glibc 2.17+ PowerPC 64-le Details
hdbcli-2.24.21-cp34-abi3-manylinux1_x86_64.whl CPython 3.4 abi3 Linux glibc 2.5+ x86-64 Details
hdbcli-2.24.21-cp34-abi3-macosx_10_11_x86_64.whl CPython 3.4 abi3 macOS 10.11+ x86-64 Details

Total release size: 51.7 MB

Release files / hdbcli-2.24.21-cp38-abi3-macosx_11_0_arm64.whl

Download URL hdbcli-2.24.21-cp38-abi3-macosx_11_0_arm64.whl
Size 5.0 MB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
f6ceaf45d9c5a9c2f47794e1ff19bc22eee8d3e018465c2c665853879e525029
BLAKE2b-256 checksum
How to use checksums
f797c2e694a91a973380ef2368ca1b12e1cea1bdd1c806886cac41dea4b6bd42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.1

Release files / hdbcli-2.24.21-cp36-abi3-win_amd64.whl

Download URL hdbcli-2.24.21-cp36-abi3-win_amd64.whl
Size 3.6 MB
Tags CPython 3.6 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
d59c2a8ea59d63aa5128e8bcbb96f568e238fb37e93c655790efa0f1c0756b2b
BLAKE2b-256 checksum
How to use checksums
28a3e64590442e05a960f83c24280b72a3ad81f66245e88f6e1103e5233ac4d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.1

Release files / hdbcli-2.24.21-cp36-abi3-win32.whl

Download URL hdbcli-2.24.21-cp36-abi3-win32.whl
Size 3.6 MB
Tags CPython 3.6 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
105a8435fb3492f33a1492079d6846a13d8b273e4de37c6a298a01d82ffe0ab3
BLAKE2b-256 checksum
How to use checksums
bd9825d25ce560b4bfbce213f43a849bbc952b87d8d13408bbf315d77c497286
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.1

Release files / hdbcli-2.24.21-cp36-abi3-manylinux2014_aarch64.whl

Download URL hdbcli-2.24.21-cp36-abi3-manylinux2014_aarch64.whl
Size 11.2 MB
Tags CPython 3.6 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
9c7e7d6cfb12e1441b7fd1e866668334755faffed3902bcbbb7a4fe9a4fd7188
BLAKE2b-256 checksum
How to use checksums
d3360df4e7bc977db0e11de8104aa22290a603db173ba3285d5e7b93d543c5be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.1

Release files / hdbcli-2.24.21-cp34-abi3-manylinux2014_ppc64le.whl

Download URL hdbcli-2.24.21-cp34-abi3-manylinux2014_ppc64le.whl
Size 11.4 MB
Tags CPython 3.4 Linux glibc 2.17+ PowerPC 64-le abi3
SHA-256 checksum
How to use checksums
6c280a548a3fa4a76eb0fbfe9188429276f80f301f98f6e5297e3561017120d6
BLAKE2b-256 checksum
How to use checksums
7504d4147f0d39fc918678fc792b392d424ebe04e26bda1279a82eeb32294069
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.1

Release files / hdbcli-2.24.21-cp34-abi3-manylinux1_x86_64.whl

Download URL hdbcli-2.24.21-cp34-abi3-manylinux1_x86_64.whl
Size 11.3 MB
Tags CPython 3.4 Linux glibc 2.5+ x86-64 abi3
SHA-256 checksum
How to use checksums
e716e8cedd6456604c33ef5a91722a3f63fe1af1d706b6552f32f890465b374a
BLAKE2b-256 checksum
How to use checksums
427d32c8cd25ba1ee5af5f2fb67cf11c9f40f3e875183ef58995c5e0afd08811
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.1

Release files / hdbcli-2.24.21-cp34-abi3-macosx_10_11_x86_64.whl

Download URL hdbcli-2.24.21-cp34-abi3-macosx_10_11_x86_64.whl
Size 5.6 MB
Tags CPython 3.4 abi3 macOS 10.11+ x86-64
SHA-256 checksum
How to use checksums
5af28153b2262466d99408977e706eb13edaf0b3a75692c5205c6a3e595e4103
BLAKE2b-256 checksum
How to use checksums
982028a07f71a7d53629ac3b3b7c059f4aa2798355a41f31e86202c0da4efe00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.1

Release history Release notifications | RSS feed

This release

2.24.21 This release

7 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page