Skip to main content

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

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

If you're not sure about the file name format, learn more about wheel file names.

hdbcli-2.30.24-cp310-abi3-win_amd64.whl (3.8 MB view details)

Uploaded CPython 3.10+Windows x86-64

hdbcli-2.30.24-cp310-abi3-win32.whl (3.5 MB view details)

Uploaded CPython 3.10+Windows x86

hdbcli-2.30.24-cp310-abi3-musllinux_1_2_x86_64.whl (6.0 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

hdbcli-2.30.24-cp310-abi3-manylinux2014_x86_64.whl (5.9 MB view details)

Uploaded CPython 3.10+

hdbcli-2.30.24-cp310-abi3-manylinux2014_ppc64le.whl (6.2 MB view details)

Uploaded CPython 3.10+

hdbcli-2.30.24-cp310-abi3-manylinux2014_aarch64.whl (5.6 MB view details)

Uploaded CPython 3.10+

hdbcli-2.30.24-cp310-abi3-macosx_13_0_x86_64.whl (5.8 MB view details)

Uploaded CPython 3.10+macOS 13.0+ x86-64

hdbcli-2.30.24-cp310-abi3-macosx_13_0_arm64.whl (5.3 MB view details)

Uploaded CPython 3.10+macOS 13.0+ ARM64

File details

Details for the file hdbcli-2.30.24-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: hdbcli-2.30.24-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.8 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.1

File hashes

Hashes for hdbcli-2.30.24-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1fbc0d8caa010ffb5a9c8828609a72f40ea34f336a680a5095efade39db788ef
MD5 7d8d5f603602a9b5c4340b1c2ec38a62
BLAKE2b-256 f41ef8af1a5a837ce36cfaab076431c78bbc0f59606d11baeb823e21b2befcb8

See more details on using hashes here.

File details

Details for the file hdbcli-2.30.24-cp310-abi3-win32.whl.

File metadata

  • Download URL: hdbcli-2.30.24-cp310-abi3-win32.whl
  • Upload date:
  • Size: 3.5 MB
  • Tags: CPython 3.10+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.1

File hashes

Hashes for hdbcli-2.30.24-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 8dfd2639e72fb1cfab72dc4b1193f10b546bc4b41c77edb52dc469fef9abdd10
MD5 312e04a28b94c1316ea2d83308b90198
BLAKE2b-256 cb8f3420d0ab67380796ef1b6b55adf136d8d3b7e901e8df4338d7135b504ea9

See more details on using hashes here.

File details

Details for the file hdbcli-2.30.24-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for hdbcli-2.30.24-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 72d9ad71693638eaff3423f7ba35f357db3990f4ae35d6291b9c8d2373024d8c
MD5 f53e95593fe6dad910624180e05450b0
BLAKE2b-256 85ace2d26821e21d0f1b247182c5fa3f0599c09ed4da526b907a3bdd8626a289

See more details on using hashes here.

File details

Details for the file hdbcli-2.30.24-cp310-abi3-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for hdbcli-2.30.24-cp310-abi3-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 72ef5b946a2fbce4eca2223af21b50c9b9f2c0f0e79e79bd6a3ec19b3895a1ff
MD5 6466c395306c769e4007dfcb8ee2d68a
BLAKE2b-256 5ff9bc8e776b4fa7d2b43e6dfe3d284081913f5c974802966062723d0590f387

See more details on using hashes here.

File details

Details for the file hdbcli-2.30.24-cp310-abi3-manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for hdbcli-2.30.24-cp310-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 c18d25b4fcbc171719f9d0fda80adc554bff866957bbf0f16e65f9e975432d5b
MD5 7f4b28e3eafd563795ea9fd5aad2982d
BLAKE2b-256 a76a260716dd8107377c855d7bc0431b55215b36ff393042ad283645b142af34

See more details on using hashes here.

File details

Details for the file hdbcli-2.30.24-cp310-abi3-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for hdbcli-2.30.24-cp310-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c1ca71da0541b11bbe26cd32f3c426dbd446cdc6a0a6a4ece7ef0e49c151e15e
MD5 6a841582db1f07ac74ff58b61afead7f
BLAKE2b-256 aea339e5bd5bcc5678467c513afd2ad9d1d85c4a40ebb61b64e83dffc2e5297b

See more details on using hashes here.

File details

Details for the file hdbcli-2.30.24-cp310-abi3-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for hdbcli-2.30.24-cp310-abi3-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 ebcc8ac24e993671c6e80f0d9ee45c33d5d4d7bfa62115e5be49c0d50cb99f5b
MD5 0e37692c027abe77125c3d621dd8ca53
BLAKE2b-256 5314973d79a00fd352497f04b7bc78693516aa2cde3bad994a06c9e212803ca8

See more details on using hashes here.

File details

Details for the file hdbcli-2.30.24-cp310-abi3-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for hdbcli-2.30.24-cp310-abi3-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 049b397532c0df9d4985de53be9bfa6f8d5704519ac6217858d6e52ecde77189
MD5 85ba3334bde78690558927c2867913ed
BLAKE2b-256 ceca580cb9cd4b1e6c8a4d843895c7e859fa6011dd57e1e5a7339a7c174a8faa

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.30.24 This release

8 files

2.29.27

8 files

2.29.25

8 files

2.29.23

8 files

2.28.22

8 files

2.28.21

8 files

2.28.20

8 files

2.28.19

8 files

2.28.17

8 files

2.27.24

8 files

2.27.23

8 files

2.27.19

8 files

2.26.26

8 files

2.26.25

8 files

2.26.18

8 files

2.25.31

8 files

2.25.29

8 files

2.25.22

8 files

2.24.26

7 files

2.24.24

7 files

2.24.21

7 files

2.23.27

7 files

2.23.26

7 files

2.23.24

7 files

2.22.32

14 files

2.22.29

14 files

2.22.27

14 files

2.21.31

14 files

2.21.28

14 files

2.21.26

14 files

2.20.23

14 files

2.20.22

14 files

2.20.15

14 files

2.19.21

14 files

2.19.20

14 files

2.19.18

13 files

2.18.27

14 files

2.18.24

14 files

2.18.22

14 files

2.17.22

14 files

2.17.21

14 files

2.17.14

14 files

2.16.26

14 files

2.16.21

14 files

2.15.22

23 files

2.15.19

23 files

2.15.17

23 files

2.14.24

22 files

2.14.23

22 files

2.14.22

22 files

2.14.18

22 files

2.13.22

21 files

2.13.21

21 files

2.13.13

21 files

2.12.25

21 files

2.12.22

21 files

2.12.20

21 files

2.12.13

19 files

2.11.20

19 files

2.11.14

20 files

2.10.20

20 files

2.10.15

20 files

2.10.13

20 files

2.10.9

20 files

2.9.28

20 files

2.9.23

20 files

2.9.19

20 files

2.8.22

20 files

2.8.20

20 files

2.8.16

20 files

2.7.26

20 files

2.7.23

20 files

2.7.21

20 files

2.7.17

20 files

2.7.16

17 files

2.6.64

16 files

2.6.61

16 files

2.6.58

16 files

2.5.111

16 files

2.5.109

16 files

2.5.105

16 files

2.5.101

16 files

2.5.86

16 files

2.4.202

13 files

2.4.194

13 files

2.4.191

13 files

2.4.182

12 files

2.4.177

12 files

2.4.171

11 files

2.4.167

11 files

2.4.162

11 files

2.4.155

11 files

2.4.151

11 files

2.4.142

11 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