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 to create a database connection string in your code will be located in the Auto-generated section on the Variables tab of an environment, like here:

Environment variables

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.

  • On GCP, the Cloud SQL Proxy will be used, so your application will connect with a local socket.

  • On AWS, we connect via a database endpoint with credentials that are stored in AWS secrets manager.

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: