cancel
Showing results for 
Search instead for 
Did you mean: 

Connect SAP CAP project in BAS to Postgres database

pascal_renner
Explorer
0 Kudos

Hello,

I need help connecting a SAP CAP project running on the BAS to a postgres database hosted on the BTP.

I setup a project according to this blog with regards to the github projects of cds-pg and cds-dbm.

I created a service key in the postgres database instance on the BTP and stored the credentials in the env file for VCAP_SERVICES.

Trying to deploy with cds-pg (npx cds-pg deploy --to db) executes without an error but nothing is deploy. However trying to deploy with cds-dbm (npx cds-dbm deploy) results into an connection error.

How do I properly setup the project so I can deploy to the postgres database from BAS?

View Entire Topic
0 Kudos

You will need to setup an ssh tunnel with port forwarding for accessing postgreSQL server from outside Cloud Foundry environment. The same setup explained in Export Data from PostgreSQL Service Instance | SAP Help Portal can be used.

pascal_renner
Explorer
0 Kudos

Thank you for the resource. I established a ssh tunnel successfully and setup a fresh project like here: https://github.com/sapmentors/cds-pg.

I set the credentials according to the service key, the host to localhost and the port to the port i opened with cf ssh command. However, the deploy command still can't reach the postgres. It fails with a connection refused on port 5432 - but i specified 63306 on the ssh tunnel and put that into the credentials. Any idea on how to fix this?