Once the client software is installed, locate the file hdbcli-x-y-z.tar.gz. The next step is to install the Python hdbcli package. This can be done easily using the Python utility program pip. Execute the following command in a terminal.
pip install /path/to/hdbcli-x-y-z.tar.gz
After the process completes, the Python hdbcli package will be installed. Listing 1 below shows a simple script that tests the database connection.
from hdbcli import dbapi connection = dbapi.connect("SERVER_HOST", PORT_NUMBER, "USERNAME", "PASSWORD") print(connection.isconnected())
Replace the connect arguments to reflect your own systems credentials. The SERVER_HOST can be an IP address or a host name.
The script will print True when a successful connection is made.
SQL statements are executed on a Cursor object. Listing 2 below shows a simple SQL statement that returns the current date.
... cursor = connection.cursor() cursor.execute("SELECT NOW() FROM DUMMY") row = cursor.fetchone() print(row)
Notice on line 2, the cursor() method is used to return a Cursor object. This object is then used to execute SQL statements.
The execute() method returns a Boolean value indicating if the statement executed successfully. The Cursor object exposes several methods to return data. The fetchone() method is used to return a single row while fetchall() returns multiple rows.
If Table Exists Function
In this article, I explain how to create a function to determine if a table exists in SAP HANA.31 October 2019 - 3944 views
Connect To HANA DB Using NodeJs
This article explains how to connect to a SAP HANA system using the Node HANA client library.28 October 2019 - 3594 views
Adding Auto Numbers To Table Columns
This article explains how to create an auto generated column using IDENTITY.14 March 2018 - 1941 views
Connecting To SAP HANA Using PHP ODBC
This article describes how to install and configure PHP odbc to connect to a SAP HANA system on Ubuntu 16.01 December 2017 - 4491 views
Connect To HANA DB Using Java
This article describes how to connect to a HANA DB system using the ngdbc.jar Java driver.03 November 2017 - 3121 views
Loading And Unloading Column Table Into And From Memory
This article explains how to load and unload a column table into and from memory.18 October 2017 - 1956 views
M_SERVICE_MEMORY System View
This article explains how to view detailed information on memory for HANA services.01 August 2017 - 2863 views