Time to Complete
A How-To that shows how to integrate python with the SAP HANA database server
In many python applications, you would need access to a database for storing, retrieving and other uses of data. In this How-To, you will use a sample database connection program using SAP HANA Client that provides python connectivity to SAP HANA libraries and executables.
Navigate to the path where HANA client is installed and then copy these three files
__init__.py, dbapi.py, resultrow.py. By default, the SAP Client is installed at:
Microsoft Windows :-
Linux Platform :-
Then go to the
Python directory under
hdbclient directory and paste all three files into the
pyhdbcli.pyd files from
Do the same as step 2 above, paste the files into
Python/Lib directory. Now you are done with the configuration part.
In this step, copy and paste the below code in an editor and save the file with the
.py extension. In the below example, The port
3< instance number >15 matches to the tenant database named
import dbapi #Replace with your hostname, unique port for the database you are connecting, #UserID and password in that order. connection=dbapi.connect('hxehost', 39013, 'system', 'MyPassword') #This statement prints true if the connection is successfully established print connection.isconnected()
Copy the file into
Python directory of HANA Client and execute in the same directory using command
Or if you are using python IDE, assign
python.exe from the same directory as the python executable.
Run the program and if the program prints True, then the connection to SAP HANA database is successful.