How To

Connect to a database

Development environment

From a workspace, you will connect to the database using a host and port. The appropriate variables to find the values and create a database connection string in your code will be located in the Auto-generate section on the Variables tab of an environment, like here:

To determine if you are on a workspace or in a deployed environment, your code can look at Environment Variables most notably COHERENCE_DEV.

Feature or Production environment

Find the appropriate environment variables to configure your database connection string. The Cloud SQL Proxy will be used, so your application will connect with a local socket. You can find the path to the socket in an environment variable, as well as other required variables like database name and password, on the environment section of the Variables tab of an environment, like here:

Previous
Add environment variables