Introduction
- This tutorial will guide you through the steps to connect your Prisma with your PostgreSQL database hosted on Square Cloud.
- First, you need to have an active paid plan on your account. You can view our plans and purchase one according to your needs here.
- Next, you’ll need a PostgreSQL database hosted on Square Cloud. If you haven’t created one yet, you can create it here.
Prerequisites
- Before you begin, ensure you have created database in Square Cloud and connect on some SGBD client like dbeaver or any other to create a database.

- You will also need to have Prisma set up in your project. If you haven’t done this yet, you can follow the official Prisma documentation here.
Steps to connect Prisma with PostgreSQL
Get Database Connection Details
Get your PostgreSQL connection details
To connect your Prisma application to your PostgreSQL database, you need the following connection details:
You can find these details in the Square Cloud dashboard under the “Databases” section. Click on your PostgreSQL database to view its connection details,
then go to its “Configuration” tab to find the connection string. If you didn’t copied when created, you will need to regenerate the password and paste it in the URL.
- Connection String: The connection string to connect to your PostgreSQL database.
- Certificate: The SSL certificate for secure connections, use the
.pemcertificate.

Creating the client-identity
Prisma requires the SSL certificate to be in a specific format, a Replace 
.p12 file. You can create this file using OpenSSL.
Before running the command, copy the downloaded certificate.pem and in one of them, open and removes the key part, leaving only the certificate part,
in the other, remove the certificate. Remember to rename them to cert.pem and key.pem to identify which is which.
To convert the .pem files to .p12, you can use the following OpenSSL command:path/to/key.pem and path/to/cert.pem with the actual paths to your key and certificate files.
You will be prompted to set an export password. Remember this password, as you will need it later.
Save the client-identity.p12 file in a folder within your prisma folder, for example, in a folder named certs.
Update Prisma DATABASE_URL
Update your 
.env file to include the connection string and SSL configuration.
In your Prisma project, locate the .env file and update the DATABASE_URL variable with your PostgreSQL connection string.
Make sure to include the SSL configuration in the connection string. It should look something like this:

