Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@prisma/adapter-pg
Advanced tools
This package contains the driver adapter for Prisma ORM that enables usage of the node-postgres
(pg
) database driver for PostgreSQL. You can learn more in the documentation.
pg
is one of the most popular drivers in the JavaScript ecosystem for PostgreSQL databases. It can be used with any PostgreSQL database that's accessed via TCP.
Note:: Support for the
pg
driver is available from Prisma versions 5.4.2 and later.
This section explains how you can use it with Prisma ORM and the @prisma/adapter-pg
driver adapter. Be sure that the DATABASE_URL
environment variable is set to your PostgreSQL connection string (e.g. in a .env
file).
driverAdapters
Preview feature flagSince driver adapters are currently in Preview, you need to enable its feature flag on the datasource
block in your Prisma schema:
// schema.prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
Once you have added the feature flag to your schema, re-generate Prisma Client:
npx prisma generate
Next, install the pg
package and Prisma ORM's driver adapter:
npm install pg
npm install @prisma/adapter-pg
Finally, when you instantiate Prisma Client, you need to pass an instance of Prisma ORM's driver adapter to the PrismaClient
constructor:
import { Pool } from 'pg'
import { PrismaPg } from '@prisma/adapter-pg'
import { PrismaClient } from '@prisma/client'
const connectionString = `${process.env.DATABASE_URL}`
const pool = new Pool({ connectionString })
const adapter = new PrismaPg(pool)
const prisma = new PrismaClient({ adapter })
We encourage you to create an issue if you find something missing or run into a bug.
If you have any feedback, leave a comment in this GitHub discussion.
FAQs
Prisma's driver adapter for "pg"
The npm package @prisma/adapter-pg receives a total of 29,980 weekly downloads. As such, @prisma/adapter-pg popularity was classified as popular.
We found that @prisma/adapter-pg demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.