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

Uploaded CPython 3.8+macOS 11.0+ ARM64

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

Uploaded CPython 3.6+Windows x86-64

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

Uploaded CPython 3.6+Windows x86

hdbcli-2.24.24-cp36-abi3-manylinux2014_aarch64.whl (11.2 MB view details)

Uploaded CPython 3.6+

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

Uploaded CPython 3.4+

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

Uploaded CPython 3.4+

hdbcli-2.24.24-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.24-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hdbcli-2.24.24-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 49df32e35752abf457c4471d3f53f2d679703774b718fa1f34e3bb3f6ad58c3e
MD5 d7fd60a09f354d14e4b92fbc743c8796
BLAKE2b-256 8f2f6331f4927e2225cd5c9af9996291a4498b7138a36c4b3576909fb3a85382

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hdbcli-2.24.24-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.24-cp36-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7edd1a95f64c3b1d7b75dc6517ccda4cc3af97161118444c434c4b1460d69e83
MD5 98dfa688481faedc91c945b24c561c67
BLAKE2b-256 f4a6cc8c9106d4188bcee3743a6b30a57a47c14a34c9e17edd9cf6166c39d29c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hdbcli-2.24.24-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.24-cp36-abi3-win32.whl
Algorithm Hash digest
SHA256 74962038b28428ae2054833c2f44a4d6dd965931737bcf1cd4b7d8be4c83a5fe
MD5 8f1bd4b47f944025971367646bf71023
BLAKE2b-256 3e3d30eed9604b21d719ba56d088cbe75f6febb09af5a1ae209d897cc8e229e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.24.24-cp36-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 561c4edb88da04cbd8631644b5adde82cc3469cb0eaba4a111fd79345986a600
MD5 ccaac494f4126e640e91e2ba2c17f719
BLAKE2b-256 cae780ab99cd5d4f4ced1e787b5981fa0548ee7925c864a401fad1d670233d20

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.24.24-cp34-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 c30b8486c4391ea865d1ae1ab5b827a5dfb634dbd72235ad681988ade967b8c6
MD5 35a6da7418b40182ef9da74fb9fb249a
BLAKE2b-256 8e3f75555d50ba6606d701fa2312af3e20d4dd5fde23df7e1a292bc1df2c8581

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.24.24-cp34-abi3-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7cc4c2148bd3460d31ef5fc0fb90507858b42dce1ed939661f20ea2784708dc2
MD5 5278382a578d8cbbf356128700f3bc3c
BLAKE2b-256 0fbf32188682f43c545c0aed0e1f74f0e202908f483376e278a8f892a3019b51

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.24.24-cp34-abi3-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 67408d7a6225e8e61ed8cf892296ae4af7e10f30a36d6ccc674854c6b369cc13
MD5 12855a67023fdc3cdd08eefed9ebe3b6
BLAKE2b-256 db5436e29f77daa92ca636afd419b9056cc8eb7bab8cce41411837403ecf4384

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