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

Uploaded CPython 3.8+Windows x86-64

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

Uploaded CPython 3.8+Windows x86

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+macOS 11.0+ ARM64

hdbcli-2.25.31-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.25.31-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: hdbcli-2.25.31-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.1.0 CPython/3.12.1

File hashes

Hashes for hdbcli-2.25.31-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 5dbc9b5384a4a8ca1e6ca187e68f9b6be24ba2d5528fc0ac803af335829e9571
MD5 d19ae327f373ac78c9643d371aa8817a
BLAKE2b-256 029d4998fc4dff6f6c84950736c5e04ad58b2a20d4961ce451ff695d86509b40

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hdbcli-2.25.31-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.1.0 CPython/3.12.1

File hashes

Hashes for hdbcli-2.25.31-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 29bb19063729690daa111dec8928258613503ee1a7981e32bce3579069ace564
MD5 a32aab352562b7e5f30bf8d686e4336c
BLAKE2b-256 89972f47b085cb8b4c6e7e865b676f0e63c53218705043e366619ffbf6f7cb9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.25.31-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 48cd60260f3d500f9f00597a288278fac0f5af82527a04e1b8de56605c9903ab
MD5 94ff686ea4f6cc066889b5dc45d6046a
BLAKE2b-256 458ccfbaefa4c2345cbb283c037b55b99548287ac56769bba9282a0da3c8430f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.25.31-cp38-abi3-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 860191e46fc2b08f9356ece6c77b3ab1f76e2b963ffefceb8a1698b4bc5a4bf1
MD5 eaeb303c57389bb93a1bbe508dc1d076
BLAKE2b-256 25f7102632676b1e9179b73bd7c882c051c5c9efff486cb9d2bb32a0bf1285ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.25.31-cp38-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 7735cdf740908e22da22ceb8d69bbac93336163be92ab1ba1acf5f0087953d7c
MD5 dcdb4307600207ca9b38ee16f3c24d43
BLAKE2b-256 9853493f3a4401bf5f3d12088a9826f8c5ce491dfa7914576e5bb1a4d8a20c6e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.25.31-cp38-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0d9df13bc19b4658a10d95aae5cc263690a87ea0cce915a9204a4739edd2703c
MD5 6c29c5472fbae29c4e07de2c41d38dd7
BLAKE2b-256 61a11ee45740a9228fd5519448b8559b4c4e696051ffcbe4f318bc69672b9f8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.25.31-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5bc895d4eae8faa8f678380e8666b5d816a2741653bee78b97ba67176341e992
MD5 aa51d5e59ab5ac4c7382e5cd40dc8923
BLAKE2b-256 aaddb2069beaa57c591caf39e730d43a8c3c21b970b814418bd709383f284152

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.25.31-cp38-abi3-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 caffb327c1c589cfb3e394fd52277d91a6c99fdece92a9b6a44104e109326407
MD5 eacc7a7d5e9ace5d5af422155b89c290
BLAKE2b-256 a103687b11d816dae17853d84deef5e2a7ad67cf0163670a106bf5e2d614b447

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