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

Uploaded CPython 3.8+Windows x86-64

hdbcli-2.26.18-cp38-abi3-win32.whl (3.3 MB view details)

Uploaded CPython 3.8+Windows x86

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+macOS 11.0+ ARM64

hdbcli-2.26.18-cp38-abi3-macosx_10_15_x86_64.whl (5.5 MB view details)

Uploaded CPython 3.8+macOS 10.15+ x86-64

File details

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

File metadata

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

File hashes

Hashes for hdbcli-2.26.18-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 18380c823bee54d23fe2bb79c56cfd0a7b5a4b17493eb51f04be8be738510c08
MD5 7de1557769e6babcabf8818e6dc45bff
BLAKE2b-256 648c7cf07819c5cd56db653c5680ae3592c18814f01e83acc08b026f8d2e2bab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hdbcli-2.26.18-cp38-abi3-win32.whl
  • Upload date:
  • Size: 3.3 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.26.18-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 e095fbc5db7b1f500151fb3017f454131ed7b7a58d9a10cba43ea6b962733852
MD5 8d01cf7204e72e42fca99630311c5c56
BLAKE2b-256 af31f2de9f1e130cc11e4be0e53afdcab6527b884dd025a04bab33684b6abf36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.26.18-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9099f19d5dc07670710b769305845974c4b8e717fe18bcc8c46898d16b2ed5e2
MD5 7475510a357341734184101dd35743ff
BLAKE2b-256 9ec36f89f54a0724c26921d1fbc7cdc8b848c9cd1cdfa360d418fea22b19b265

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.26.18-cp38-abi3-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8c6f8b188d3bd0a51175b0ba4bca0279b0207ff8eeaf6730956da8d406511d43
MD5 884ec721447f81d7417f4d1c97924207
BLAKE2b-256 0b7e4bb02270886939ec417fb005ea2d7d8d669dd5cbe2cab6523fae937acfca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.26.18-cp38-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 1de3d06e4371f252280041629059a4633aca904aed9365330291dbb279bff5a6
MD5 361d6f4767351dc34ef181be428a5cd6
BLAKE2b-256 d18d607c57f57526725b6bbb6dffcdf56737a2ea92a41207d77b43c0312282e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.26.18-cp38-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 762b693584e49cb8e0baee52af4ed9181c9a99c3b5097e19ffdcd3d967e772fb
MD5 53d8cbebf9b24b170c121aeb315d9b29
BLAKE2b-256 4f3c2f57cf8bc6e4a9d9b76ab3c54a99e4b09a9b1e5c95b5b5ae1b9def76ed50

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.26.18-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8438ea58c326cf844dd5ba41fb6bfae1b53dab7f92c7ba656b521a6b07c98d66
MD5 47de8e618630e7a9a8e49c2ff14dead0
BLAKE2b-256 74c8b2e3a6c25c727cd4547ea92a50a83fc0ac04e5b972e7ea5b8d708bc2eb6e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.26.18-cp38-abi3-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 6ca8928d22b22b15c910abd52bf36cd04b9d0afda2d75e5e505b8aa006bffe26
MD5 2addea4197b31ea7b1ccc82d7a986ff9
BLAKE2b-256 abf6324f4ef1380aa1309cf04283a06e78be9525bcfacc3bcd4801807eec7d5a

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