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_USERNAMEthe username to use when connecting to your database. (e.g.:
WDPR_DB_PASSWORDthe password to use when connecting to your databse. (e.g.:
WDPR_DB_HOSTthe host where your database is running. (e.g.:
WDPR_DB_PORTthe port on which the database is running. (e.g.:
WDPR_DB_DATABASEthe name of your database. (e.g.:
WDPR_DB_CONNECTION_STRINGa database connection string containing all information necessary to connect to your database. (e.g.:
You can also find this information in the settings screen of your database:
See also our article about How to configure your preview with env vars and Docker build-args.
Do you have any questions or remarks? Just send us an email to email@example.com. We are happy to hear from you!