Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP data output to python ?

Former Member
0 Likes
3,042

How to access SAP data from windows python, i am working on some projects where i wanted to deal with SAP dataset with Python, need to add rows and columns and modify them from python code. Is there any API or integration by which i can access SAP dataset ??

5 REPLIES 5
Read only

FredericGirod
Active Contributor
2,059

Did you check if your Python could access SAP data through Odata ?

like that https://github.com/SAP/python-pyodata

Read only

thomas_mller13
Participant
0 Likes
2,059

Create a Webservice via TA SICF. There are many tutorials in the web about that. You have to implement the interface if_http_extension and register your class in SICF as a Webservice.

https://blogs.sap.com/2016/10/23/creating-class-handler-sicf-service-code-example/

Read only

AndreasForster
Product and Topic Expert
Product and Topic Expert
2,059

Hi Ranveer, There is a fairly new Python interface to interact with HANA data. https://help.sap.com/doc/1d0ebfe5e8dd44d09606814d83308d4b/latest/en-US/index.html

It allows you to work with the HANA data through Python without having to download the rows. Below is a very basic example, which calculates a new column. The outcome can be saved as view in HANA, it can be persisted as HANA table, or the modified data can be downloaded as pandas dataframe if you must.

import hana_ml.dataframe as dataframe
conn = dataframe.ConnectionContext("hxehost", 39044, "ML", "password")
df_pushdown = conn.sql('SELECT * FROM USEDCARPRICES')
df_pushdown = df_pushdown.select('*', ('YEAR(CURRENT_DATE) - YEAR', 'AGE'))
df_pushdown.save("NAMEOFNEWVIEW", "VIEW")
df_pandas = df_pushdown.collect()

A more comprehensive example that also includes Machine Learning is described on https://blogs.sap.com/2019/11/05/hands-on-tutorial-machine-learning-push-down-to-sap-hana-with-pytho...

Read only

roberto_forti
Contributor
0 Likes
2,059

Hi, try to understand how the module "pyrfc" works.

from pyrfc import Connection.
Read only

Srdjan
Product and Topic Expert
Product and Topic Expert
0 Likes
2,059

> Hi, try to understand how the module "pyrfc" works.

hope this helps: https://github.com/SAP/PyRFC