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

Uploaded CPython 3.8+Windows x86-64

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

Uploaded CPython 3.8+Windows x86

hdbcli-2.27.23-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.27.23-cp38-abi3-manylinux2014_x86_64.whl (5.9 MB view details)

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+macOS 11.0+ ARM64

hdbcli-2.27.23-cp38-abi3-macosx_10_15_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.8+macOS 10.15+ x86-64

File details

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

File metadata

  • Download URL: hdbcli-2.27.23-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.7 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.27.23-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 517094332a8a1f5408f8c3b2c2fb4f3461fd6ee40bc0dd0e64688869c5b1ed90
MD5 4d0bdc2f010b93c0ba9d05dd15803eb7
BLAKE2b-256 9ca5765474fca0e6c9a4defd6d3f3081adb42e3a32cd11b7c321d60284cdc496

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hdbcli-2.27.23-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.27.23-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 1b58e779e6f7c6a9286c610906eb938f4d58bd2566610a652d9feee9541e298c
MD5 10821a8629104a82f4a3e1a67a9dcecc
BLAKE2b-256 b14684ab17619614b4853fd2ce79b0687986fe16d1f453bb40a1b53a2167550f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.23-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 bf910189ac8b07c1fd81bcd74ac3420a5520017b5d4f0c90cdb8209f425f9d80
MD5 d0fd766ed4f02f0fd3c9c785ed158dc5
BLAKE2b-256 095a4b7bf201f99a811c25ffd0502e05f9ae0ae516d7bdff6ef2a0cd3359a68e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.23-cp38-abi3-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 de365f863235d8dbbe7da5a5eb0dd0d3da94cbbea535d50b76b5d998f38df1e4
MD5 ab66ccf1a5539e65cf55f03f96725bdd
BLAKE2b-256 806a8cb87ac64b62f1975a9a3ea4171c584a00e35995fb16c80d160edf757409

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.23-cp38-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 aa3989ee1be84ed43c6bf8e0ee8d66ef6b5c82fca22055945caf6133f068397a
MD5 193259f2a75d1e251e1145fc9f290500
BLAKE2b-256 0897cc2eb0c1e4ded4b151ab571ac6863e41bc597dd504faaae090d7af638234

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.23-cp38-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4a542a77828130b210a064acede764c14d57b085fdb2dcbf97d7cd59728bf49c
MD5 53b788f3e869cbd8094ac93e365c49b5
BLAKE2b-256 6aef4a36a25b2a023676428f6114f5275ba75446310b208621943f56d514812b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.23-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a946b1d06edd7eb182d2c9c6194052ded08a32ebd63abb72571d2c9626e61371
MD5 e45e2adecafb99797618ce7b8522a2a7
BLAKE2b-256 98b4172280730b884bb68382190001ae26abaf4763feabd0efe71cc55dae24f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.23-cp38-abi3-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 bd9f83b1d2bb567bd32f7728a4af8e1d04c237cfe02d160572c4c834c6fc2f99
MD5 578c77d1d6bb4dd75452c8a17e536f78
BLAKE2b-256 d19c9fd2bfd166ac6cbd12c31dab81fec75e693b5348df4839f51a0b26c0df3c

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