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

Uploaded CPython 3.8+Windows x86-64

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

Uploaded CPython 3.8+Windows x86

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+macOS 11.0+ ARM64

hdbcli-2.27.24-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.27.24-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: hdbcli-2.27.24-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.27.24-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 240a712f8b8ca205198b41ce5936fdef96bdd913119a275f4926b7ae063910b9
MD5 3009dc06b50406ad694dc5282508e0a8
BLAKE2b-256 77d527ae8b6ff84ec06edf4cbdca4aad11fad20f728197b23b4dca474d666bdb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hdbcli-2.27.24-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.27.24-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 21adbb297ec3b354f529a0eac42e341838f5ab134e31d21d1603f6de4b1aee5e
MD5 2dcd31bd29d91424862dd46ad1f6c51b
BLAKE2b-256 fbd3369682ca3b0f6ba5848bb2c55e0f4322f1fea921ee04495050544f8be18d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.24-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5fa5048ed2a51629b80afa30e63445ca2881ffb36862d54b30f1fa657bee0396
MD5 6abd028c2475427ad4254cd78e7209ce
BLAKE2b-256 847f6a00e5d43014493c3ecacf57334c1f52a7005a517fd34922c43de6f79b9a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.24-cp38-abi3-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3be05dc041e971c0508a4c5ff9ee4752a3a09fb5eb31f9d007fe42e99556659c
MD5 2b7ee16b24f3a54e86ec1429b4836f26
BLAKE2b-256 2a00b22b1a54c0fa49154c7bbe050e56c59c69de671936f2fdba9042a87e6c9f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.24-cp38-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 7a1aa6c658e728eb214f1d72866e833bb870e07b7aac6e1dec58000790ebe118
MD5 060004668dc66cd96ddd73861ae7f8dc
BLAKE2b-256 151c39b1d4997c9c802b41f74810d98382bc936af985d3420a093126a033ded8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.24-cp38-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5fda06d03c66a87493d508d5d16bb5a083de15fcc0f3e2b67904beeadd8de6b0
MD5 58ad333c44c9fb05f9e21e3dff6e5c44
BLAKE2b-256 ddd97c75696bc132a70277425bf4464b1fe94b02baea293daf9343ac14875f9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.24-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 42787a4e7e76097c7b331c1672c755439b88df8893f71e716a8526218dbc08ee
MD5 79f5cd7aea7b4ccba7355222c1fb8f25
BLAKE2b-256 e16813904e4e1e571a534acc8a8c6dae13a91e4061568966b2e574a02f19be97

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.27.24-cp38-abi3-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 77185f07fd96c01eca16b7c1b9b85c8a02236b75f63db4751a0ebfd9ee4cab7f
MD5 8b59fa6081f84287ba060f32faa1a88e
BLAKE2b-256 b63849a0e70b169c052516ceb87163f0e0e0663c702b1118a80bba4195d85e60

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