Skip to Content

Connect to database in SAP Cloud Platform from Python App

Aug 30, 2017 at 01:52 PM


avatar image
Former Member

I have connected my database instance in SAP CP using Python app. I am using pyhdb library to connect. For that, I opened the tunnel and it works fine. The parameters I passed to pyhdb is my (IP address as host, port 30015, my user, my password)

But when I try to deploy my same app using cloud foundry, I get connection refused error.
Any help or pointers?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Ivan Mirisola
Dec 29, 2017 at 03:17 PM

Hi Prathamesh,

Your app needs to deal with different configurations when you deploy locally or in the cloud environment.
When you deploy on CF the manifest file needs to point to the related backing service and from your app perspetive happens on the localhost instead of your tunnel. You need to read the environment variables and look for the VCAP_SERVICES. There you will get the backing services assigned to your app with all connection details, like port numbers, users, password, etc. So you don't need to worry about those when your app runs.

Check this blog to see how a local connection is made to MongoDB using NodeJS.


10 |10000 characters needed characters left characters exceeded