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

Uploaded CPython 3.8+Windows x86-64

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

Uploaded CPython 3.8+Windows x86

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+macOS 11.0+ ARM64

hdbcli-2.25.22-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.22-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: hdbcli-2.25.22-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.22-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 39be35b8c605d728252408c1ed21bf84abe1f8a088d3917c862ecb83d0803457
MD5 18cd71a37c4c0e57a5b327ab3c4456e2
BLAKE2b-256 465dfe27b5e121e362e508d6c950d22ff343538ef20a10c62bd0d9da0fc0a1cb

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for hdbcli-2.25.22-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 f00607262a12f23f472facd6bdb490b922ac69c8f4ac16cdd1e34fbf2054c824
MD5 91918a8ae5e6351fac27ed6290cb8fbb
BLAKE2b-256 103627aa293d4ba5fc46ef17ef06e4d3eedee621996d1ed3325c7fe6b642c21f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.25.22-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 58a1fc8e90e0e764ddf8bd1c5ab1ef4b1bf3b5897a19dd41b216b4d149275e74
MD5 8ba2adb383794788e6b4cc2ea5393c89
BLAKE2b-256 116138efe31bece44599d5662bccbeb3ab144bbae23b58803f20c01bf715d3c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.25.22-cp38-abi3-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 348d2ac6a2eaed68cb07013a3d3fc5483c5de6cbfdd7e6190baed139e8e5bb73
MD5 2b25a9ec2de2a59b623ee61a6a32b3b9
BLAKE2b-256 b61ff271459fa1c9c28b6fb02c22e92883e0fcab09d0f077a0a9f2dbdf7b7332

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.25.22-cp38-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 09f5aab989a86987a0ca85575267963daeb0e2e38ddf1f8044dfec142093c083
MD5 7fc4bacbeda8c1435c0bfb222def2b77
BLAKE2b-256 feba91e911511fb76a1af352e605206537905aa544b24da8f37a0c7373c6d532

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.25.22-cp38-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 85c4721c1b6805564d422470a22ac17e75c88fba456d1ce10f84d21764f82bdb
MD5 ab28b15ed8731fc1c6e41d89f706ff20
BLAKE2b-256 4aa3ecb3cbebbd6fc4b3a6fcc57fd437153364256195267564ca1e5b4b4e277a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.25.22-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7fcbd25cdffc2a350bec45e617cfa8f0f96d83486080e0b77f66983c2be97b02
MD5 b8005211ac2efe7ffaa15305bc7fbf99
BLAKE2b-256 08bb16175d08cce4942e2c894e384b69f196e0bf6d68f74ddefcb5f45712b74a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.25.22-cp38-abi3-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 fe62301e07a06cf57ba18a4ca5987d4d43e13e196a432f23bf8c40aca84bd576
MD5 e84ba68d153702f8e6a72c90687cff7b
BLAKE2b-256 23099726b9d777c6960b94d2874cddb53aa7083319ae81b51eb8e1b2be1a5e5a

See more details on using hashes here.

Supported by

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