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

Uploaded CPython 3.8+Windows x86-64

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

Uploaded CPython 3.8+Windows x86

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+macOS 11.0+ ARM64

hdbcli-2.27.19-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.19-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: hdbcli-2.27.19-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.19-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a3b0bd8285c5f7fb41e740dcd34ce6d6be9722e6f682a1cfcf5ed63cfd0e32e5
MD5 5d22b372c1eac8c80fb67626cacffae0
BLAKE2b-256 a8492b1d54491fbee8051d042bb896e42c2777a75933ed71290c03a4c058afd0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hdbcli-2.27.19-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.19-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 038bd7191d96e14b486fd2c027564f4aea64c56d839cbb0b26ad43b28f9cb716
MD5 a242c1fe3a7964675e5fd3943ea9940c
BLAKE2b-256 e4c394b7c336fa585d3d0a5199d3f1f0246d9e84a363472f67178afb0a381c82

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.19-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ba548a08173c3bfdc30c8d20eadb45e51604cb885ffb9ca8241e1fe410677c02
MD5 fcffe3b2ded97685984c1b4d933fee51
BLAKE2b-256 0c20a4ea945a03d16fe55736ea13fd270d10a13107117abe1e421b643d95917a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.19-cp38-abi3-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fc361dc9b05b936159012e90d31d8c51e4b2b5a3981b0bb7f080d5267c73f2f7
MD5 5e6a2aad029018ca129e9dccbf522c2d
BLAKE2b-256 88261d16f58922ad5d106e7511f5706ab58224ab89b89892bc744d29c90f8da0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.19-cp38-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 84613398ae2198a9cf02ed8aa5f980caeb14f4b4ea7984eaf474bd4f1a87ea35
MD5 da263216af61e1b396f99b0fa3e0d302
BLAKE2b-256 da650147a930cd20ee1a34bdd428b47d65d0631613703ef9059c8cb776de3c86

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.19-cp38-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4962a1c7648ed237318b5c15fd2f12c2e85539ea242d64536827202df2b6120d
MD5 1cc5b9e48f8dbd568f5b7186ceb5e93f
BLAKE2b-256 1bb27e6476139025c633dae32645c339d931a07cf10c158ef3e9313d880ae126

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.19-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f9a994669c3d7761db95a823a97535d97897694f9cb7805f787225fcfcc375ff
MD5 09ba9709d68eff7c8f876296085e7c2f
BLAKE2b-256 f9fea4721a3090030f5c6c7b871752816b85a102e50fd751a716b5fe3eb47b50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.19-cp38-abi3-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 5b91fc6eca13c11e31a031bbb4b859151fe5e9fad4b8c71c96620882bbb32377
MD5 03ccf59a3f61649e12807f8486bb497c
BLAKE2b-256 80659fabc4a96d96b5432f18aea973c9ee08840d1231cabf5d7297fd0f8bd805

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