cancel
Showing results for 
Search instead for 
Did you mean: 

Using python to access SAP HANA database with Single Sign On

former_member752777
Discoverer

Hi,

I have been connecting to the SAP Hana database in python using pyhdb library in python using this format:
pyhdb.connect( host="", port="", user="", password="" ) and it was working great.

Recently things have changed and now I will need to be able to access a database through single sign on and windows log in credentials. I have tried several things with 2 other libraries pyodbc and dbapi. If there is something I am missing or if any one has any idea of another way to access the DB would be very helpful.

Thank you so much in advance!

former_member30
Community Manager
Community Manager
0 Kudos

Hi and welcome to the SAP Community!

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers (if you haven't already), as it provides tips for preparing questions that draw responses from our members.

Should you wish, you can revise your question by selecting Actions, then Edit (although once someone answers your question, you'll lose the ability to edit the question -- but if that happens, you can leave more details in a comment).

Finally, if you're hoping to connect with readers, please consider adding a picture to your profile. Here's how you do it: https://www.youtube.com/watch?v=F5JdUbyjfMA&list=PLpQebylHrdh5s3gwy-h6RtymfDpoz3vDS. By personalizing your profile with a photo of you, you encourage readers to respond.

Cheers,

Julia
SAP Community Moderator

martinstenzig
Contributor
0 Kudos

Could you provide a few more details as to how you envision the SSO to behave? Do you expect you to run a python script and it automatically using your windows account? Are you packaging the Python code into flask and want to use SAML?

former_member752777
Discoverer
0 Kudos

Yeah the goal is for the python script to connect with SAP HANA using my windows account and credentials. Essentially the credentials I used to login into the computer.

Vitaliy-R
Developer Advocate
Developer Advocate
0 Kudos

dkumar1997,

Regarding "the goal is for the python script to connect with SAP HANA using my windows account and credentials." is your SAP HANA database configured to accept your Windows login?

I think point 16 from https://launchpad.support.sap.com/#/notes/2159014/?anchor=L16 might be relevant in your case.

AndreasForster
Product and Topic Expert
Product and Topic Expert

Hello Dheeraj, Please also consider this documentation. https://help.sap.com/viewer/0eec0d68141541d1b07893a39944924e/latest/en-US/b250e7fef8614ea0a0973d58eb...

Patricularly the table at the bottom: "If either or both the <UID> or <PWD> parameters are not specified, Single Sign-On (SSO) information is provided to the SAP HANA server:"

I had a customer once who wanted SSO logon to SAP HANA with the Python hana_ml package with SAML. That's the pseudo code. The customer then had to obtain the SAML ticket from their internal system and pass it to HANA

samlAssertion = customerSpecificAssertionfromIDP() # pseudo code to be replaced

import hana_ml.dataframe as dataframe

conn = dataframe.ConnectionContext(address = 'yourhanaserver', port = 12345, password = samlAssertion)

Accepted Solutions (0)

Answers (0)