How to connect to my WunderPreview database

WunderPreview gives to the ability to add a PostgreSQL database to your account. Each GitHub organization that you have added to your WunderPreview can have one database.

The database runs in the same cloud infrastructure as your previews and is only accessible by your previews.

But: How can I connect to this database?

The answer is as so often: environment variables!

There are a number of environment variables injected into your previews containing the information necessary to connect to your database.

The environment variables are available during build-time of the container that will power your preview and also during run-time of your preview.

Here is the list of environment variables and what they contain:

  • WDPR_DB_USERNAME the username to use when connecting to your database. (e.g.: myorga)
  • WDPR_DB_PASSWORD the password to use when connecting to your databse. (e.g.: j235h23l4j234h2klhfdlakf)
  • WDPR_DB_HOST the host where your database is running. (e.g.: postgres12.wdpr.run)
  • WDPR_DB_PORTthe port on which the database is running. (e.g.: 5432)
  • WDPR_DB_DATABASE the name of your database. (e.g.: myorga)
  • WDPR_DB_CONNECTION_STRING a database connection string containing all information necessary to connect to your database. (e.g.: postgres://myorga:j235h23l4j234h2klhfdlakf@postgres12.wdpr.run:5432/myorga )

You can also find this information in the settings screen of your database:

WunderPreview database settings screen showing how to connect to PostgreSQL database.
WunderPreview database settings

Do you have any questions or remarks? Just send us an email to hi@wunderstack.io. We are happy to hear from you!

Keep things moving with automated previews.

Screenshot of WunderPreview Dashboard