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

Uploaded CPython 3.8+Windows x86-64

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

Uploaded CPython 3.8+Windows x86

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+macOS 11.0+ ARM64

hdbcli-2.28.21-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.21-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: hdbcli-2.28.21-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.21-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3b50c7d6cd0c66cec6650eaef27c8a99d318e9186d0dc65cb3a4fd4cc2803acc
MD5 88f3a056b06ac1ac04f9e1731e37b86c
BLAKE2b-256 39ddfe2e866747e35ecc9ea818fc5760aa8d1d525bc90af8f96063720b0a1973

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hdbcli-2.28.21-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.21-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 ac64ca3d08f96179fe7e9f3a60d5dfc6a6f0951adc221b09eb001f3f458bb9f8
MD5 1e80d499d1f68998e0171c156a14034b
BLAKE2b-256 1e8eb6e0cbbaaf3384af01dc3d4c52a8015fedf5ad13fa383cff518ccdf6fb20

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.21-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6592d1127549ca8c05161a40350d64bd69a5e3a924979f38e403fb2711c94862
MD5 5f3e29b4203f6d89a5e8285abc82450c
BLAKE2b-256 630e71bfb5519c5310b172f77095ed6b5c55c0177a0d34bc039b8f6fd7a7f38c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.21-cp38-abi3-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e11081c3683a78f7791a2a8afb22f6567acf118cffe62fb7ca8a13e31d0c644a
MD5 56b905b83d6dcd1698c721b9fd7468ab
BLAKE2b-256 cd53a875c6fd275b0eb741c48552b9c2f61b42d99280d3739e6304374a36f35b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.21-cp38-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 bcc80757ab6fc785a5288cff4b8f7dc51e45b216d1f788a36257e2d3ebb1fe2b
MD5 1a225bc0b33c590dc5eccf53be366d1a
BLAKE2b-256 548dcda7447d817ccee5b680a7c0b786e8e51c0fee9321d1352626c14a0d4d2a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.21-cp38-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b3d3d2bfd093754ee94c2300d59fc9d53a1dd5fad940af460724391ecafe7d03
MD5 afe0bb146f4a45a899c9331566206b72
BLAKE2b-256 c693c699fbb1266cb5dde1d71b9f21b0df15d8285d3b2f71ca079f28b54ef7eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.21-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6845184d91e5d4c13312d1e59b4e0c4a13811312e05f96cf0481ce2906cf0552
MD5 83c463301114b28dcd10badb9602e645
BLAKE2b-256 6d643fd965c984784e2d82cd683926b441c1ce48b7d7c88ed1ed31162f522949

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.21-cp38-abi3-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 d84203f7e8bc6a21dd348040d15ced7a678db1446a268ba1a03d35a11e4edf20
MD5 2ae939c8621304a95ad0fc71dc2fdcfa
BLAKE2b-256 0ce4e6cafe09df6451ab1d384d23c408cf71ade7de1460f9176a0790a733f213

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