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

Uploaded CPython 3.8+Windows x86-64

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

Uploaded CPython 3.8+Windows x86

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+

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

Uploaded CPython 3.8+macOS 11.0+ ARM64

hdbcli-2.28.22-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.22-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: hdbcli-2.28.22-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.22-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 41c60ca06934be3743b154ae5c4c8b3fc175d23b023156cd4f0e5045a46589f7
MD5 31b0e294e664649211f3179b0b75153a
BLAKE2b-256 351d0b33675603740e81ff6b96331f8bfe28d4b0338907ec8b5eb9e5e1947a34

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hdbcli-2.28.22-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.22-cp38-abi3-win32.whl
Algorithm Hash digest
SHA256 4fedfeb898d5e058538856f569ccfa0f8c0e38509e20a30a0834171ce95fdf6f
MD5 73df209278e60e16991dd2b52adaf59b
BLAKE2b-256 bdfa23ade1b568c5a7d09fca5eb4838e9dc73cc4a0897e7987b2c2cf4ac51f85

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.22-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9609863d932f48d94333612b80d1905c9045f27c12649cbe4b14f307eda0e756
MD5 5955f46c5127696c968e0636e2626764
BLAKE2b-256 935c7f8fc1dfd8d801a88ec5e8c7dcd5a5383f0aff1df7ee68a141ff383a1bca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.22-cp38-abi3-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 277f5de80296aaeced6d46d734fa047994f9dc5ca1b34ffbcd68c69a9be93801
MD5 5c6093a1444d31d1598b0512eb5294ea
BLAKE2b-256 ee7ea4ef607ab086df60a6f2a6241b3eb9adcdfc4b7261bfffd1030446cfa8be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.22-cp38-abi3-manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 db7663117919f663c691ee187f835a8916c0200cf07b67ce7aad4a4268fc23f4
MD5 3d32e916668eaf7cb2a09d15e9ece84c
BLAKE2b-256 774c9605534a1f7f356b0114b720d598aa12187e4c7eb5b33d863f1e077ff0ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.22-cp38-abi3-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e465ae23b13d11afaf141c5893f81155e70072a1e668d4131232a1111d395ec5
MD5 6006bc73b46c433c0ce4cf54c89f9581
BLAKE2b-256 20853959a7eb99da74466b73c63a7b871604d9bbb52d17b2f30e07022f30b5ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.22-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7483649bd89a61a5df51240e94bfc88dc5a9f59659ca7a333dab353fb3e38dcb
MD5 43e31043f1921a95cf263ca3d09f9d34
BLAKE2b-256 76115d78c0ccf3c11cb5899ea879e8ff4df2452725354f56ab19c8f557ab333e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hdbcli-2.28.22-cp38-abi3-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 f962b5b192c8867c00458818b4b40399eb90cad36f7c4decef90ffe062e12a32
MD5 6b870ec8f0f1a0e626737c345eb8c40f
BLAKE2b-256 a087211796399275a453f32aa900293e986ceafc9ed33bf83df7d379a3aaf3cb

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