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

Uploaded CPython 3.8+Windows x86-64

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

Uploaded CPython 3.8+Windows x86

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

Uploaded CPython 3.8+

hdbcli-2.28.19-cp38-abi3-manylinux2014_ppc64le.whl (6.1 MB view details)

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

hdbcli-2.28.19-cp38-abi3-macosx_11_0_arm64.whl (5.1 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

hdbcli-2.28.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.28.19-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: hdbcli-2.28.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.28.19-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6693c84fbf3c97a4345d77c8247fb72da36e300665026ddcda422c2470f8b22b
MD5 b1feec2b1530248eefa6bd85b1a28920
BLAKE2b-256 30f81160b1e6eb899b72369cbbc02ec6e997bbc43fa1e9bbc808eaa3728b3021

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hdbcli-2.28.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.28.19-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 715499808eb41226b85696b6f6ac14d766f1ce044fdea531a317e39cbfc5218f
MD5 126447961bfc44b75c3d6a8b53bcfbd3
BLAKE2b-256 7d1a87d9853610abf3678414c1fa58c6a670b222469c7f8c9830e3b658223806

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.19-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0f0f9baf0105335b594cbdfbbd9d2f7b1d88f111068bb0af12b00dd984d58bef
MD5 622fb10e3f1b207d52920750d19ed27e
BLAKE2b-256 40dd74ad7bfe55ecb20cacc6a72d00e6ff80ad7fd34533aa60938a81126b4a7f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.19-cp38-abi3-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b78699e0492292098ea60c3f123a7e773e56a44735a21e571c71ac282692cadb
MD5 1c5cde72598d1d754043be792bb7a8bf
BLAKE2b-256 65fec74f8b43efa659b1e62a591435b75de82ec5c26a25e1a9d6bb55e8e15712

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.19-cp38-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 b88f02736c979e5f8521c958bdd8fe8dc939e9b9562ed084f15a1c98db0542a8
MD5 8f1d55b7079e79b4b9a4f9a07229e049
BLAKE2b-256 090db149f6c7eabd3196b0b75ab5fe0b10befdc87ec154c73bc79234400611cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.19-cp38-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6fd7024fd8afbd17efd85da42ee35c0129a688f769c0eb08257f4c9f28d9467f
MD5 7e00a3634743484f7563b6e912db374a
BLAKE2b-256 dfc465b07158fd1a61d9722530ae04c0cc0cba95bf6a2d5047000b5ce5fec116

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.19-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cd809b7e904c7e1315d23db9a721b73e9dd5b65a4801d8cabfcca2100b3a151c
MD5 43008135b2171e235a04e568fe476c23
BLAKE2b-256 1c9154165183d56611f144a14233357b7a8b88b23dad20212b76ca2b7f2e0971

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.19-cp38-abi3-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 911f48316b69f83c87669ee68bf146c761562a7ab8aea1166f0e43610c3e2801
MD5 0353cb3bff232f86b0e481693a3095a0
BLAKE2b-256 965213bfccb15563247ca651da97f462e172cc7fbfdb22d70bcd107798bc04ed

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