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

hdbcli-2.23.26-cp38-abi3-macosx_11_0_arm64.whl (5.0 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

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

Uploaded CPython 3.6+Windows x86-64

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

Uploaded CPython 3.6+Windows x86

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

Uploaded CPython 3.6+

hdbcli-2.23.26-cp34-abi3-manylinux2014_ppc64le.whl (11.3 MB view details)

Uploaded CPython 3.4+

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

Uploaded CPython 3.4+

hdbcli-2.23.26-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.23.26-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hdbcli-2.23.26-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 77340ceefa3d38cfc11bd15b158d39432f1332373ac76a8185d2017625e7b1ec
MD5 4a4fb15b4d44b45ff93c2ba54af4c579
BLAKE2b-256 87eca18fa8286e4af702c6170c3d01e78062aaee27fb21361f4823cb7f8b0f0d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hdbcli-2.23.26-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.23.26-cp36-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 465d7816f16fac4fbddd3825bda75fdd9f842550eacb2f1b6828111df91b9ba0
MD5 d368d9e9c89dd787f84c7a29543e2ead
BLAKE2b-256 8632c2b4a7ac7a9dfdc16c178078dadd35c53555197d1de7c2567e9bb47443ab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hdbcli-2.23.26-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.23.26-cp36-abi3-win32.whl
Algorithm Hash digest
SHA256 21a77f5811b5864568699e5d862f6f461f38aff33033ff7a4425ed1aa02b2b85
MD5 b05139f8c93ffa0588aec1947d5cc430
BLAKE2b-256 336eb8347891b01d250037a6067879bb8767f6b8d08be46f3c32a9216250b12e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.23.26-cp36-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7924f936480c85eccfca52eab85867a0d87b37b926c6a308125fd94db30973c2
MD5 5d9bd8ba88d8295eaef786864d3fcad9
BLAKE2b-256 233ffc9a9f1b77b441e1c109be32ce97277665b27c4a04636fdaa93c776685d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.23.26-cp34-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 bedf21b7065cf1d0a0c161615d0c24a8e7cf6a57fe252dd3a1cada1d32b25062
MD5 58055bf60ec44d4bd1d85e1eed23e9d6
BLAKE2b-256 e397f936f6cbaa85e82c8e26ddcc55677733f420d6a0e2d984c5a8ac28430ef4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.23.26-cp34-abi3-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3b4e432e089e2627a75dc9774afc1119d5390d328a0680cd13d414a4fcb0b710
MD5 4c36b0bdcd5339d6f19986ea495aa4ea
BLAKE2b-256 4a7a915c80a3513493bab4f2af8a20ed899d823de32c78788a710b0cd3c53353

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.23.26-cp34-abi3-macosx_10_11_x86_64.whl
Algorithm Hash digest
SHA256 b6d532667231c35ad14283c60a05e151e14c11be0278e9cb845fe6bde41bb0ce
MD5 0675e8dfc51e2dd1074dfcc3e9384982
BLAKE2b-256 04bc700682cdf1995c6807566b7080ff6da1bf004ad20a784a3bfa2fef4cd57a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page