Skip to main content

SAP HANA Python Client

Project description

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

Project details


Release history Release notifications | RSS feed

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.26.26-cp38-abi3-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.8+Windows x86-64

hdbcli-2.26.26-cp38-abi3-win32.whl (3.4 MB view details)

Uploaded CPython 3.8+Windows x86

hdbcli-2.26.26-cp38-abi3-musllinux_1_2_x86_64.whl (5.8 MB view details)

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

hdbcli-2.26.26-cp38-abi3-manylinux2014_x86_64.whl (5.9 MB view details)

Uploaded CPython 3.8+

hdbcli-2.26.26-cp38-abi3-manylinux2014_ppc64le.whl (6.0 MB view details)

Uploaded CPython 3.8+

hdbcli-2.26.26-cp38-abi3-manylinux2014_aarch64.whl (5.6 MB view details)

Uploaded CPython 3.8+

hdbcli-2.26.26-cp38-abi3-macosx_11_0_arm64.whl (5.2 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

hdbcli-2.26.26-cp38-abi3-macosx_10_15_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.8+macOS 10.15+ x86-64

File details

Details for the file hdbcli-2.26.26-cp38-abi3-win_amd64.whl.

File metadata

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

File hashes

Hashes for hdbcli-2.26.26-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 59a6c1700b3249d68b92cc5e2d43a3d869792fea54159caa0691729dcf4e8825
MD5 e86a12e130b213a488ea15ebb1d77e89
BLAKE2b-256 6288894dde37b74d3fc5a9b95833ff1dded4367433a0c9c0faba8be4d21c03ec

See more details on using hashes here.

File details

Details for the file hdbcli-2.26.26-cp38-abi3-win32.whl.

File metadata

  • Download URL: hdbcli-2.26.26-cp38-abi3-win32.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: CPython 3.8+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for hdbcli-2.26.26-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 5fb85976d58bee65f83fd42b724c0261e97974cfa4f942630ef97df9e41fc943
MD5 659cd06832fc205e1c4b5f987a820a0d
BLAKE2b-256 c45d349599e1173a385de1459379bd945e14c4d2e6fc6d930dded67636121a7f

See more details on using hashes here.

File details

Details for the file hdbcli-2.26.26-cp38-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for hdbcli-2.26.26-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 10b03c0a3fb592800d5b167d95708af27d75fc48b8161fca3d9ac7e9a1717d3e
MD5 2845996c9cd8a5b34a0c0118c46171e8
BLAKE2b-256 abb69302ead6b58de47b9aa3e8633e68ba3a875c98fbe854b5fdf6508332dcd3

See more details on using hashes here.

File details

Details for the file hdbcli-2.26.26-cp38-abi3-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for hdbcli-2.26.26-cp38-abi3-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0c65a03cf7492d7a331d644c68a8a067de99c6eae037345215ba8868e2ff74b1
MD5 9f91050a4d88e09f7c28e7bf9883fc83
BLAKE2b-256 484f4c56f0e81a5eb04e204939b5e90a1c852f360fbae89282aaeaab7d412005

See more details on using hashes here.

File details

Details for the file hdbcli-2.26.26-cp38-abi3-manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for hdbcli-2.26.26-cp38-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 2229f0f4a58327584ed8958419a3b7a3b333bb202a50ef798e6f48cc07f6fa67
MD5 22e9339e9e131b6c0a898c9147da6bf5
BLAKE2b-256 bcc787c7c510c6907f0cef89d6c26f156b6fad58eca864715df1bcd2777d64ef

See more details on using hashes here.

File details

Details for the file hdbcli-2.26.26-cp38-abi3-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for hdbcli-2.26.26-cp38-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 eaca6df9516bdee77f7f1db5a93c67d1157aa5d54cc56c18f599d1ba83c959ed
MD5 79603a40adb5c808f1861d2babe7761c
BLAKE2b-256 5a5316395da4b161e1fddfa7e571ee57ba7e8b5a806b80fe561ab68543429698

See more details on using hashes here.

File details

Details for the file hdbcli-2.26.26-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hdbcli-2.26.26-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6923d51af191090ac0de5390dbb38d511fe5f519794778c8b0fde73656e34629
MD5 31e6ba26c8dab7156ca17dd52d7c5678
BLAKE2b-256 1037ea8df3ee6e88388405ce61e6dbf952fd8c50637f1aace08db34837d74e26

See more details on using hashes here.

File details

Details for the file hdbcli-2.26.26-cp38-abi3-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for hdbcli-2.26.26-cp38-abi3-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 c22759020dec63bd27dfc107df8da58b0783b4fbf71c8241fc12ce68dafcbf94
MD5 079f6555c8e92edab9d1703055226518
BLAKE2b-256 d54eb18af8f52a506667aff507c7503b90e6e78914c79f8c0d5a514746d1c51a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page