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.24.26-cp38-abi3-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

hdbcli-2.24.26-cp36-abi3-win_amd64.whl (3.6 MB view details)

Uploaded CPython 3.6+Windows x86-64

hdbcli-2.24.26-cp36-abi3-win32.whl (3.6 MB view details)

Uploaded CPython 3.6+Windows x86

hdbcli-2.24.26-cp36-abi3-manylinux2014_aarch64.whl (11.3 MB view details)

Uploaded CPython 3.6+

hdbcli-2.24.26-cp34-abi3-manylinux2014_ppc64le.whl (11.4 MB view details)

Uploaded CPython 3.4+

hdbcli-2.24.26-cp34-abi3-manylinux1_x86_64.whl (11.3 MB view details)

Uploaded CPython 3.4+

hdbcli-2.24.26-cp34-abi3-macosx_10_11_x86_64.whl (5.6 MB view details)

Uploaded CPython 3.4+macOS 10.11+ x86-64

File details

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

File metadata

File hashes

Hashes for hdbcli-2.24.26-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 74c4364c17b96650fd06d7de8ba6004491a9d6afbd07dc845c5907dcc6ac367c
MD5 6b10c02d09840358f00f16e97697f4d7
BLAKE2b-256 3ee7b46e8b6e45423b4bdecafeddeefde26bbeaaab08095f61a7f30499f5b063

See more details on using hashes here.

File details

Details for the file hdbcli-2.24.26-cp36-abi3-win_amd64.whl.

File metadata

  • Download URL: hdbcli-2.24.26-cp36-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.6+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for hdbcli-2.24.26-cp36-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 11fa023cbb1c5db4149f0929cca9b387ebce56c79b667e1467bf659c8d3eac10
MD5 89d80e894b9954cb5e896f82693eb600
BLAKE2b-256 6c67de22e927efc0ab263a607085db9fb16f23e3b257ca626cd9ee7281ebfad8

See more details on using hashes here.

File details

Details for the file hdbcli-2.24.26-cp36-abi3-win32.whl.

File metadata

  • Download URL: hdbcli-2.24.26-cp36-abi3-win32.whl
  • Upload date:
  • Size: 3.6 MB
  • Tags: CPython 3.6+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.1

File hashes

Hashes for hdbcli-2.24.26-cp36-abi3-win32.whl
Algorithm Hash digest
SHA256 220af424b10a4577f0292b76a088d6af6b8688aa26251c504410791aa79ee84c
MD5 252ace7ecfa3891650ff4b173e188d2b
BLAKE2b-256 ec0fd74c600733cdca2f65305a578e1619cdd1da1c3cae471dd0092b41e93700

See more details on using hashes here.

File details

Details for the file hdbcli-2.24.26-cp36-abi3-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for hdbcli-2.24.26-cp36-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 282235c9ec838cfe7b1f28069f0558e345535292e25582845167a37fc2da3d2d
MD5 ab8b364627d12620e5b98ee51a22504a
BLAKE2b-256 bf70d8f9f93f936717f33cc43e6b91d45c05002fefb190a6b7ba8b42e208d2fe

See more details on using hashes here.

File details

Details for the file hdbcli-2.24.26-cp34-abi3-manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for hdbcli-2.24.26-cp34-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 4764283f11d7eb19d78d00e97d54272e5dd11aa6688050077daae9605450eac3
MD5 4e0d158ffbc2e5e299d44ac953d338bd
BLAKE2b-256 233f1b18651da252b8e562604f917519bf70318d853e8d55763d0bc0d7172571

See more details on using hashes here.

File details

Details for the file hdbcli-2.24.26-cp34-abi3-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for hdbcli-2.24.26-cp34-abi3-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9ecb4e81facea1d3251a35da4dd102b06562b896cbe073cee14d5531327f77bd
MD5 015d2ade193a350ed1bbd3f002dcfe3c
BLAKE2b-256 b70463fb721fda110e1c93272d4685b948b4ef10f61daa37c7172e8e6e0ca67a

See more details on using hashes here.

File details

Details for the file hdbcli-2.24.26-cp34-abi3-macosx_10_11_x86_64.whl.

File metadata

File hashes

Hashes for hdbcli-2.24.26-cp34-abi3-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 741589a3c49985f55067f07cbd7f93980a5bd819f9dbdda824ee28066caa7126
MD5 d29636dffe7c1e8c0b357841843ffe79
BLAKE2b-256 1c807d3607811d80e3838b0badebcf5541874a2d404c22a6ea34f5402a782faa

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