SapHanaTutorial.Com HOME     Learning-Materials Interview-Q&A Certifications Quiz Online-Courses Forum Jobs Trendz FAQs  
     Explore The World of Hana With Us     
About Us
Contact Us
Hadoop App
Tutorial App on SAP HANA
This app is an All-In-One package to provide everything to HANA Lovers.

It contains
1. Courses on SAP HANA - Basics, Modeling and Administration
2. Multiple Quizzes on Overview, Modelling, Architeture, and Administration
3. Most popular articles on SAP HANA
4. Series of Interview questions to brushup your HANA skills
Tutorial App on Hadoop
This app is an All-In-One package to provide everything to Hadoop Lovers.

It contains
1. Courses on Hadoop - Basics and Advanced
2. Multiple Quizzes on Basics, MapReduce and HDFS
3. Most popular articles on Hadoop
4. Series of Interview questions to brushup your skills
Hadoop App
Stay Connected
Search Topics
Topic Index
SAP HANA Overview
SAP HANA Architecture
Reporting in HANA
SAP HANA Text analysis
Power of Python Integrated with SAP HANA

Python is a high level, object-oriented programming language for the web.
Python is Easy to Write, Easy to Read and Easy to Understand.

SAP HANA works pretty well with python too.
SAP HANA and Python
This article will give a basic idea of how to use python on top of SAP HANA.

Note:Even if you are not aware of python, no worries. We will cover each and everything in detail for you.

Python API:

There are several APIs available to connect python to SAP HANA. In this article we will use one of the simplest one which is DB API .
dbapi API is Python DB API 2.0.

Configure Python API in SAP HANA:

  1. Navigate to the path where HANA client is installed and copy these 3 files.,,
    SAP HANA and Python
    By default it will saved in C:/Program Files/sap/hdbclient/hdbcli folder.
    Note: If you have not installed the HANA client, then install it from here
  2. Go to the python folder under HDBClient folder and copy all 3 files into the Lib folder.
    By default the location will be C:/Program Files/sap/hdbclient/Python/Lib

  3. Copy pyhdbcli.pdb, pyhdbcli.pyd files from hdbclient folder.
    By default this location will be "C:/Program Files/sap/hdbclient"

  4. Go to the same Python/Lib folder and paste these 2 files.

That's all.Configuration is done!!

Connect to SAP HANA and Run SQL Queries using Python:

  1. Write below code in a notepad and save with .py extension.

import dbapi
## Replace SCHEMA1 with your schema

# assume HANA host id is abcd1234 and instance no is 00. user id is USER1 and password is Password1
conn = dbapi.connect('abcd1234', 30015, 'USER1', 'Password1')

#Check if database connection was successful or not
print conn.isconnected()

# create a table
cursor = conn.cursor()
stmnt = 'Create column table SCHEMA1.table1 (ID integer, name varchar(10))'
print 'table created'

# insert some data into table
stmnt = 'insert into SCHEMA1.table1 values (?, ?)'
cursor.execute(stmnt, (1,'A'))
cursor.execute(stmnt, (2,'B'))
print '2 records inserted into table'

# fetch table data
stmnt = 'select * from SCHEMA1.table1'
result = cursor.fetchall()
print result

  • Provide your HANA system details and credential in the file.
  • Make sure you change the schema name with your schema.
  • Now save this file to hdbclientPython folder.
    The default location of Python folder is "C:/Program Files/sap/hdbclient/Python"
  • Open Command prompt. Navigate to Python path and run the command

    SAP HANA and Python

  • Support us by sharing this article.

    Explore More
    Close X
    Close X

    8 thoughts on “SAP HANA and Python

    1. Shubhangi Dhawan says:


      Please share the above mentioned files :,, also.

    2. Cyril says:


      Thanks for this perfect tuto 😉

      Unfortunately, I can’t access Hana Trial Instance from Python.

      My connection in Eclipse is ok but the host shouldn’t be good …

      Do you know the right host to use to connact to Hana Trial Instance ?

      Best Regards

      • Admin says:

        Hi Cyril,
        In case of HANA trial, we normally do not get the database user. A database user is required to connect HANA thru python.
        You might also have to set the proxy if required.

    3. Gaurav says:


      I tried but each time I get the error :

      dbapi.Error: (-10709, “Connection failed (RTE:[89006] System call ‘connect’ failed, rc=10061:No connection could be made because the target machine actively refused it)”)

      Any idea ??


    4. Raj says:

      I am not able to find pyhdbcli.pdb, pyhdbcli.pyd files in hdbclient folder, is it available for download?

    5. Arun says:

      We needed 32 bit version of,, files, and we couldn’t find the “hdbcli” folder under C:/Program Files/sap/hdbclient/hdbcli, does 32 bit version of HANA Client tools have those three files at all ? Appreciate your help.


    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Current day month ye@r *

     © 2017 :, All rights reserved.  Privacy Policy