Skill 04 · Prisma Database Setup
Subchapter 4.5
references/prisma-client-setup.mdMarkdown1 KBView on GitHub
Generate and instantiate Prisma Client for Prisma’s standard SQL provider workflow. For MongoDB, follow the provider-specific notes in references/mongodb.md instead of copying the SQL adapter example below.
npm install prisma --save-dev
npm install @prisma/clientIn prisma/schema.prisma:
generator client {
provider = "prisma-client"
output = "../generated"
}prisma-client requires an explicit output path and does not generate into node_modules by default.
npx prisma generateRe-run prisma generate after every schema change to keep the client in sync.
import { PrismaClient } from '../generated/client'
import { PrismaPg } from '@prisma/adapter-pg'
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL })
const prisma = new PrismaClient({ adapter })If you change the generator output, update the import path to match. For the SQL provider workflow, replace PrismaPg with the adapter for your database.
Each PrismaClient instance creates a connection pool. Reuse a single instance per app process to avoid exhausting database connections.