Connect your database
Set up a Prisma Postgres database in the PDP Console
Follow these steps to create your Prisma Postgres database:
- Log in to .
- In a workspace of your choice, click the New project button.
- Type a name for your project in the Name field, e.g. hello-ppg.
- In the Prisma Postgres section, click the Get started button.
- In the Region dropdown, select the region that's closest to your current location, e.g. US East (N. Virginia).
- Click the Create project button.
At this point, you'll be redirected to the Dashboard where you will need to wait for a few seconds while the status of your database changes from PROVISIONING
, to ACTIVATING
to CONNECTED
.
Once the green CONNECTED
label appears, your database is ready to use.
In the Console UI, you'll see a code snippet for a .env
file with two environment variables defined.
Set environment variables in your local project
Copy both environment variables from the Console UI and paste them into your .env
file. Your .env
file should look similar to this:
DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/?api_key=ey..."
PULSE_API_KEY="ey..."
Note: The
api_key
in theDATABASE_URL
should be identical to thePULSE_API_KEY
. Don't worry too much about thePULSE_API_KEY
yet, we'll explain later why you need that.
By setting the DATABASE_URL
in the .env
file, you're ensuring that Prisma ORM can connect to your database. The DATABASE_URL
is used in the datasource
block in your Prisma schema:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
That's it! You can now start using the Prisma CLI to interact with your Prisma Postgres database. In the next section, you'll learn how to use the Prisma CLI to create and run migrations against your database to update its schema.