Application Development 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: 

SAP data output to python ?

former_member649979
Discoverer
0 Kudos

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

FredericGirod
Active Contributor

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

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

thomas_mller13
Participant
0 Kudos

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/

AndreasForster
Product and Topic Expert
Product and Topic Expert

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...

roberto_forti
Contributor
0 Kudos

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

from pyrfc import Connection.

Srdjan
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

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