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

Uploaded CPython 3.10+Windows x86-64

hdbcli-2.29.25-cp310-abi3-win32.whl (3.4 MB view details)

Uploaded CPython 3.10+Windows x86

hdbcli-2.29.25-cp310-abi3-musllinux_1_2_x86_64.whl (5.9 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

hdbcli-2.29.25-cp310-abi3-manylinux2014_x86_64.whl (5.8 MB view details)

Uploaded CPython 3.10+

hdbcli-2.29.25-cp310-abi3-manylinux2014_ppc64le.whl (6.1 MB view details)

Uploaded CPython 3.10+

hdbcli-2.29.25-cp310-abi3-manylinux2014_aarch64.whl (5.5 MB view details)

Uploaded CPython 3.10+

hdbcli-2.29.25-cp310-abi3-macosx_13_0_x86_64.whl (5.7 MB view details)

Uploaded CPython 3.10+macOS 13.0+ x86-64

hdbcli-2.29.25-cp310-abi3-macosx_13_0_arm64.whl (5.2 MB view details)

Uploaded CPython 3.10+macOS 13.0+ ARM64

File details

Details for the file hdbcli-2.29.25-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: hdbcli-2.29.25-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.7 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for hdbcli-2.29.25-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7d588b44a4baaf285c78baa3600960eac775b4e7286f4f5e0bd609dd4e3cf876
MD5 e4e321b65194041e23fe5cebb60855a3
BLAKE2b-256 6d4282832d65316ba80b87be9abbf57a3c238f558c5210635d3e1c143d6c29e7

See more details on using hashes here.

File details

Details for the file hdbcli-2.29.25-cp310-abi3-win32.whl.

File metadata

  • Download URL: hdbcli-2.29.25-cp310-abi3-win32.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: CPython 3.10+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for hdbcli-2.29.25-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 44dff5b4cb6e1e2bf21773f2fc75de9368c84f892883acfabba2aa7b59d3a23f
MD5 f093b9ab6f14005faf42436288c1919c
BLAKE2b-256 76498d86097dd5e92e756cd2b102a639f8bd78beb3d11d5af697b167900ec6b4

See more details on using hashes here.

File details

Details for the file hdbcli-2.29.25-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for hdbcli-2.29.25-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 22a574f9ed3b5f075f084ad289d127e79a6e0a08a0a1aee09efac0c4b7094394
MD5 7788ceb7e0dc60d5f9fa4c9c37427589
BLAKE2b-256 d8f05e972f9e343e434249eb7c1eea956192393cabb610f710a38c2f594cce28

See more details on using hashes here.

File details

Details for the file hdbcli-2.29.25-cp310-abi3-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for hdbcli-2.29.25-cp310-abi3-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bb2fdcd712ce10098610d2e386e9797661f98f4fa322d88fc8a9fb8615c10ba6
MD5 fd98011a40f9f9c8dfd5591d36286e14
BLAKE2b-256 5bead4bf0a571f6ef756cb6d7760c1f8365da44ded97f657701e891e69c0fa51

See more details on using hashes here.

File details

Details for the file hdbcli-2.29.25-cp310-abi3-manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for hdbcli-2.29.25-cp310-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 89a077e792df20bdc17e484af28370d3a52c7c8fb2e4099a1543ab8f95ea3996
MD5 d960e4e62e521a1f7fff98de629ff332
BLAKE2b-256 5d2c0626d20de44423664bdfd8f23079f48dc42f760a670fee9c372006c11049

See more details on using hashes here.

File details

Details for the file hdbcli-2.29.25-cp310-abi3-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for hdbcli-2.29.25-cp310-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 44a0424d094eefb43caa41dbf903c8f1d68e0a7fc8f1e3f3e641710175017341
MD5 71f5e99c9bf190b14b7120533a2ea05f
BLAKE2b-256 430282ddc20456df0216928fa54d7e513738aa1b1ef2119b1710b28a6eb52581

See more details on using hashes here.

File details

Details for the file hdbcli-2.29.25-cp310-abi3-macosx_13_0_x86_64.whl.

File metadata

File hashes

Hashes for hdbcli-2.29.25-cp310-abi3-macosx_13_0_x86_64.whl
Algorithm Hash digest
SHA256 d3b90f6536048f9d0087673f100a1a7e9fd2c52dcec8e0a38d7f84e14ec70d6b
MD5 407d9be37fdf8e9b3a4b00be0d7f60f2
BLAKE2b-256 a225fe1af7baf116dfcc105abce80efe0c6ee18f9f4d956326ff34c1e91f3b73

See more details on using hashes here.

File details

Details for the file hdbcli-2.29.25-cp310-abi3-macosx_13_0_arm64.whl.

File metadata

File hashes

Hashes for hdbcli-2.29.25-cp310-abi3-macosx_13_0_arm64.whl
Algorithm Hash digest
SHA256 c08c985d943e56863714aa4b03a9336ae4ea867af089bf8a9c5ae32c52644196
MD5 beb7db56b5051b979fe96ada8748494c
BLAKE2b-256 c144bc2115493693f43ef2c6ccc11f3ddb4d2108b663f05b4ef734eedd443ba7

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