Skip to main content

Initial Setup and Configuration

2. Initial Setup and Configuration

Installation

To use Prisma, we installed it as a development dependency in the project:

npm install prisma --save-dev

Initialization

The Prisma CLI was initialized with the following command:

npx prisma init

This created the following essential files and directories:

  • schema.prisma: The schema definition file for our database.
  • .env: Stores the database connection URL.

Database Connection

In the .env file, the database connection string is defined. Prisma reads this URL to connect to our PostgreSQL database.

DATABASE_URL="postgresql://username:password@localhost:5432/mydatabase"

This connection allows Prisma to execute queries, migrations, and data retrieval directly in PostgreSQL.