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

Uploaded CPython 3.10+Windows x86-64

hdbcli-2.29.23-cp310-abi3-win32.whl (3.4 MB view details)

Uploaded CPython 3.10+Windows x86

hdbcli-2.29.23-cp310-abi3-musllinux_1_2_x86_64.whl (5.9 MB view details)

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

hdbcli-2.29.23-cp310-abi3-manylinux2014_x86_64.whl (5.8 MB view details)

Uploaded CPython 3.10+

hdbcli-2.29.23-cp310-abi3-manylinux2014_ppc64le.whl (6.1 MB view details)

Uploaded CPython 3.10+

hdbcli-2.29.23-cp310-abi3-manylinux2014_aarch64.whl (5.5 MB view details)

Uploaded CPython 3.10+

hdbcli-2.29.23-cp310-abi3-macosx_13_0_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.10+macOS 13.0+ x86-64

hdbcli-2.29.23-cp310-abi3-macosx_13_0_arm64.whl (5.2 MB view details)

Uploaded CPython 3.10+macOS 13.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for hdbcli-2.29.23-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0381c40ffdf026faff5f67901c400382a0890feebfccf40819fdaaa62f5ae872
MD5 443172b8d420f8749d555f868b426e57
BLAKE2b-256 e58af6c5fec1e671004f85e742cfd3b878d1b27ccaef30cf5291a433a1d929c5

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for hdbcli-2.29.23-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 850bab92deeac7575f5bdf5d23bf1169e8c4ce40e9db805e6015b929c6f5dc8d
MD5 79b5a177f636d91ebf8c0d7ac9b4d580
BLAKE2b-256 e8274538b545723df7bf1baee1833c37a057a12db5db55fc1fca27a78f1d5fb9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.29.23-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d8c30b1d6cc53cfe6f05fffa49c9e5dda3c0eee829d13632f67a80181f9dcd1c
MD5 155844f166b444c17b5e58bfa5fcfcfd
BLAKE2b-256 132650972918d1918aa1cba9a3b187d812fb10ae795003f676201644e38c4d99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.29.23-cp310-abi3-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d34962d35a0811ca24a7c02d92af3981b3503a80626c4423a497cd00d615b68f
MD5 dd81867e5c90aadc98d96d7e972fcbd6
BLAKE2b-256 31d1b88dfbcde56398b0edcab0c1e0039801d998a2823827180c583453bcac54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.29.23-cp310-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 16357c0110e7625cb80aeec558ff9e1b30837d0a35b8c8e21f6f2d3fea10cb89
MD5 98021da44efe046ff4152df4615cc5de
BLAKE2b-256 5d766f55cb8fdc424de75628ebe3ee2cad71ac65a6648a275a11c9ec1ca0a096

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.29.23-cp310-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0a03c320ad915d50e892b9885e3ffbe20f35862e53b34b7fb481ef01aa008e60
MD5 3c8c100f8ad58dbf8c70890c0c9f8d74
BLAKE2b-256 6118b1717b086bc223c1b079d73270d6e499bc4bd56d2684206336942ecdb08e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.29.23-cp310-abi3-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 be0d2810a387999463a21a4a7b681342a2162e6dc9f9e9d9fa42cf6b888d4946
MD5 bf4a4e2c2bd2fbab1a9922d62f73531d
BLAKE2b-256 f5b7f424df623c02cff066a650db6af78f76f981c73ee9c7f8510917990d91e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.29.23-cp310-abi3-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 ad83b110c6e6ca5de87bdd7390e168e852c57712e66c85f6b96f3f2eb35f1e16
MD5 44b45182f517302be75deb54f09ecdd8
BLAKE2b-256 71022f274dd086b015efd766d52da98d13a9e12c8a86d13123e48a68eae5612a

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