-
Notifications
You must be signed in to change notification settings - Fork 877
Open
Description
Following overview to initialize Prisma ORM with PostgreSQL there is a confusing part where instantiation of Prisma client example leads to problematic and mysterious issues even if adapter has valid connection string:
ERROR: SASL: SCRAM-SERVER-FIRST-MESSAGE: client password must be a string
Solution
After session of debugging I've found the solution that PrismaPg expects not connection string but pg.Pool or pg.PoolConfig. Without providing this pool instance PrismaPg tries to create an node-postgres instance with blank configuration. So we can improve Prisma documentation with following statement:
import "dotenv/config";
import { Pool } from "pg"; // <-- Import Pool from pg dependency
import { PrismaPg } from '@prisma/adapter-pg'
import { PrismaClient } from '../generated/prisma/client'
const connectionString = `${process.env.DATABASE_URL}`;
const adapter = new PrismaPg(new Pool({connectionString})); // <- Use Pool with connection string
const prisma = new PrismaClient({ adapter });Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels