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

hdbcli-2.23.27-cp38-abi3-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

hdbcli-2.23.27-cp36-abi3-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.6+ Windows x86-64

hdbcli-2.23.27-cp36-abi3-win32.whl (3.6 MB view details)

Uploaded CPython 3.6+ Windows x86

hdbcli-2.23.27-cp36-abi3-manylinux2014_aarch64.whl (11.2 MB view details)

Uploaded CPython 3.6+

hdbcli-2.23.27-cp34-abi3-manylinux2014_ppc64le.whl (11.3 MB view details)

Uploaded CPython 3.4+

hdbcli-2.23.27-cp34-abi3-manylinux1_x86_64.whl (11.3 MB view details)

Uploaded CPython 3.4+

hdbcli-2.23.27-cp34-abi3-macosx_10_11_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.4+ macOS 10.11+ x86-64

File details

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

File metadata

File hashes

Hashes for hdbcli-2.23.27-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5a608df24dc0603347af6f0764262eaae8d5c4f38fa65d8a45a9f8013da05897
MD5 552e73f669abbfa60dd86562e26ecb0b
BLAKE2b-256 e0b9a8fc747338be1837fc809b509f6a8986fa2519d23a8dd4a34c5cb5c7e0c0

See more details on using hashes here.

File details

Details for the file hdbcli-2.23.27-cp36-abi3-win_amd64.whl.

File metadata

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

File hashes

Hashes for hdbcli-2.23.27-cp36-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1b7fc5a77be5050b25daee19c934a14ccca4a1444ad5e03086ee2759759212d1
MD5 727e49eef2a52e120e5144e1033b2d95
BLAKE2b-256 536f99e308b2ebbdfd740191959850ff5a9368bf7dcadc5b27eea70906c4c453

See more details on using hashes here.

File details

Details for the file hdbcli-2.23.27-cp36-abi3-win32.whl.

File metadata

  • Download URL: hdbcli-2.23.27-cp36-abi3-win32.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.6+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for hdbcli-2.23.27-cp36-abi3-win32.whl
Algorithm Hash digest
SHA256 704a4db7ceec2a6720d8f45ebe1b1d2e58bf63ccf2a98b32cc21fab35e4dced6
MD5 fcd070f933729e4bdee24d416aaf6970
BLAKE2b-256 4660aa202a9d8dc78c8e3679e94fae316c58de59585ec828ba6829a2e7a00a13

See more details on using hashes here.

File details

Details for the file hdbcli-2.23.27-cp36-abi3-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for hdbcli-2.23.27-cp36-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0451b25065a72a4021a432e11b92305b467324d5b8f7857aecda90b822d362fa
MD5 2f519cf11a53602f005b6174c436a71b
BLAKE2b-256 a82d71177be91d7a26e566d75ccffb27ebe627bb8daef29ffee3e889f3b158a0

See more details on using hashes here.

File details

Details for the file hdbcli-2.23.27-cp34-abi3-manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for hdbcli-2.23.27-cp34-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 3dac578618cc93774bcc88e612893931e22dfd408dfe393696568980d095071a
MD5 2eb26bf149eec568332b2d5e53349766
BLAKE2b-256 00390fd40b6ed0256470e02cd39ffd79f1805769744c4b4c2f8dded6efdc8c51

See more details on using hashes here.

File details

Details for the file hdbcli-2.23.27-cp34-abi3-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for hdbcli-2.23.27-cp34-abi3-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2cbe9d84af3e00489d59afdc8e0c4c1c59f722fef9a6da161ee6b9a71be9c080
MD5 4de8e89372b6e24206f7e163a5016cfe
BLAKE2b-256 265e2a2ac180ec34efb9ef39eeb59041881dbdd945f1782a897386d75043dca9

See more details on using hashes here.

File details

Details for the file hdbcli-2.23.27-cp34-abi3-macosx_10_11_x86_64.whl.

File metadata

File hashes

Hashes for hdbcli-2.23.27-cp34-abi3-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 fa374b439493e653fb57b9f03dde78daf7fa00053abb424f61f48cbe431a232a
MD5 17fdc1d021091638ff2dc7975280c904
BLAKE2b-256 ec6e15da733bdcc4af5889cb9f8e08d0b411db4b985bb2758ce42bcc4eb26f98

See more details on using hashes here.

Supported by

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