Every application needs to store data in a database at some point. You'll learn how to get a production-grade database from Qovery in just a few seconds in this guide.
Before you begin, this page assumes the following:
- You have already deployed an application with Qovery
Tutorial
Qovery supports most popular SQL and NoSQL databases (You can see the complete list here). In this guide we will deploy a PostgreSQL database and connect it to our NodeJS app.
Create a PostgreSQL database
Connect your application
Now, we need to connect our application to our database. The credentials (URI, Username, Password ...) are available through environment variables. They are injected by Qovery when your application runs.
To connect our NodeJS application to our PostgreSQL database, we only have to:
- Use the NodeJS PostgreSQL client (pg)
- Use
QOVERY_DATABASE_MY_DB_CONNECTION_URI
into our code
Add the
pg
dependency intopackage.json
{/* ... */"dependencies": {/* ... */"pg": "^7.17.0"}}Connect our application to PostgreSQL (see documentation)
const { Pool } = require('pg')const pool = new Pool({connectionString: process.env.QOVERY_DATABASE_MY_DB_CONNECTION_URI,})// your can use your connection pool now ...Nothing more, well done! You can now be able to use your database.
Next Steps
Congratulations, your application has access to your PostgreSQL database. Now we will see how to add your custom domain to your service.