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

Uploaded CPython 3.8+Windows x86-64

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

Uploaded CPython 3.8+Windows x86

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+macOS 11.0+ ARM64

hdbcli-2.26.25-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.25-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: hdbcli-2.26.25-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.25-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 84ebea96b2883b6a566306a2bf1b92bf4ca6a822f6330c50be9ab882f2b0f899
MD5 5b86e76fc73a67749337ab1b991678a6
BLAKE2b-256 814f0e3f7a2eadc7ff616f2c5b21e6a7f44989ba2e49ebe057a807a1946287fc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hdbcli-2.26.25-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.26.25-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 39273c712f325b204c46145a45d447d19fba2a1e4b13d3717f1f53fc30721a54
MD5 3f9fe91c7df211b894dd3ce1f592d33f
BLAKE2b-256 8e1b0758e08f23e3277370336ade7724aaf2b029e0379b3c6d00927844cd591d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.26.25-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c40088be658d22c9f26fd0ab6c5eb1c715afd8d75a968e978bf251d5c89470f4
MD5 a54e786cab30dc70dfdd0a1195955dce
BLAKE2b-256 d98ff1e5f76b3f8c0c7ab5f07bb3cd0cbc0129aeecbf5b86aa0400a98abe440c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.26.25-cp38-abi3-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0fd25d3ae408c14413c51a52751e6946eb2a1963045e8e14dabde27266a17779
MD5 ea0c7cb96a51573ad7ade3815a1ace8f
BLAKE2b-256 7fbb8d319d5539c912615869629ff86e00a782712446ce12560d8adc64a874ce

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.26.25-cp38-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 94d820732bae94d870a2f49c2e8b1fff3473d255d0b42c1f6bd53caaa6f0faaa
MD5 f46819fe9df8c15d182fd2bacc98d59e
BLAKE2b-256 bcd55d63620c14ba589dda622b613f4a19a276f6db5f30dfcd3fbd3d875dd0de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.26.25-cp38-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 96bce90963992766da3bd3a0b7d35524b020bc400275fc9c63dc088948c03eb1
MD5 f62fa39b1e544d1a4201fa81c18ea4a8
BLAKE2b-256 6147f565e4104a4ad18ff6a830163da40381ee31ec1a8ce4b9e10a5b978c8bb0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.26.25-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c465139cf523708e89acb0812719b1061cd7c984c3f9340b45d1ff108373d485
MD5 53d9e1b4bda9ee68651978a488f907f7
BLAKE2b-256 deca90d6fdfd83c49bd39c70e1f019b6cfffe54d37da87069146b2248a951ea4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.26.25-cp38-abi3-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 c15a671c9330540444bd4c34dd2b87d9f95170ebb8cdd74c328e4c0367ffa7a2
MD5 10d1e202a279848578cbb44d1c19535f
BLAKE2b-256 905c579693b953614ed2bdc01c94c56277aaf08cbf24d99abfd6933d4dc1eb36

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