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

Uploaded CPython 3.8+Windows x86-64

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

Uploaded CPython 3.8+Windows x86

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+macOS 11.0+ ARM64

hdbcli-2.28.17-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.17-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: hdbcli-2.28.17-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.17-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 946dc3965dd8838c47c2dfee69707b1bb4ffc9e6f64916c7f23e7da894b0fce0
MD5 0d9305e9c6ea0e09ef71a6f63243f21b
BLAKE2b-256 c63afd72c361e0ea2b5e1e125478d711b56983319f60ff7d4e1aecfb52ea69fb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hdbcli-2.28.17-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.17-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 558d5d6d8204d48a034daf149b1cfe5e3dc7ca4d5ae9199e7b754620587168ad
MD5 ba56318153427df7cd9e263c1f780f33
BLAKE2b-256 d065694d7922462e0b76afbef24a4a430b9293a86d87281c177bb1ec929d096d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.17-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0085ec4d45907c9c8a23b0ee8a52c7eac6a7cfa3af2f6034d47ab4a0a6728761
MD5 715910abce181b684d7034216cb35477
BLAKE2b-256 78dc3d1161d07d5a2f426713a4150f067553a93f12c91037ebe987778defa755

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.17-cp38-abi3-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3ac614aba48f734986937efd25db40f89954455b9870ea301c72e890195b727c
MD5 7916b979214d5612e8c8d0878eb16e51
BLAKE2b-256 8c90964df08e1cf6c5649bdfd00db15ec87dc727abfde7294005e8b35decda11

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.17-cp38-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 3c705b067ebf6b5911321f8179cb656be6237966265310ad26d7e924b6c2a79f
MD5 46df9e39f8c4539d9b72d00e5e040638
BLAKE2b-256 92ccd5d5192fe3d24e1380737702043431558fa11d3a442f8f264bfbf448507b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.17-cp38-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3060a222aa38bc0f6b3dae13e7303f56d7e3ba23a0dd8196e45b333add268e9a
MD5 1bd0e1d95ad0d43dcb6707eb78edabb1
BLAKE2b-256 ed20f4884d01be3968cf833462c390be7923fe16f4907c396f128eee4f8b0082

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.17-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bea2fc9cb5798297b0fb992d93bedf10509a6ecb3f6b1185dc1d04422bf68527
MD5 e4c0abdeb4acf6793f2e4d65813bb134
BLAKE2b-256 f27d33cb88d79a4b8b42b9423f1b6f0b382ab9603accf675c95256711dc7bfd8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.17-cp38-abi3-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 05e5141563590169e5b6fe04bee972950edd51e7ab735b129c21896f89cc0198
MD5 747ffe734f7ea2d9099a4a6eb1709813
BLAKE2b-256 a624434aa8525e269b4466cd5fee11edb3f922d44b57480c3b6d68192ad673f5

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