Skip to main content

Connect your database

Set up a Prisma Postgres database in the PDP Console

Follow these steps to create your Prisma Postgres database:

  1. Log in to .
  2. In a workspace of your choice, click the New project button.
  3. Type a name for your project in the Name field, e.g. hello-ppg.
  4. In the Prisma Postgres section, click the Get started button.
  5. In the Region dropdown, select the region that's closest to your current location, e.g. US East (N. Virginia).
  6. 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:

.env
DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/?api_key=ey..."
PULSE_API_KEY="ey..."

Note: The api_key in the DATABASE_URL should be identical to the PULSE_API_KEY. Don't worry too much about the PULSE_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:

prisma/schema.prisma
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.