Database drivers

Default built-in drivers

One of Prisma Client's components is the Query Engine . The Query Engine is responsible for transforming Prisma Client queries to SQL statements. The Query Engine connects to your database using the included drivers that don't require additional setup. The built-in drivers use TCP connections to connect to the database.

Query flow from the user application to the database with Prisma Client

Driver adapters

Prisma Client can connect and run queries against your database using JavaScript database drivers using driver adapters. Adapters act as translators between Prisma Client and the JavaScript database driver.

Prisma Client will use the Query Engine to transform the Prisma Client query to SQL and run the generated SQL queries via the JavaScript database driver.

Query flow from the user application to the database using Prisma Client and driver adapters

There are 2 different types of driver adapters:

Database driver adapters

You can connect to your database using a Node.js-based driver from Prisma Client using a database driver adapter. Prisma maintains the following database driver adapters:

Serverless driver adapters

Database providers, such as Neon and PlanetScale, allow you to connect to your database using other protocols besides TCP, such as HTTP and WebSockets. These database drivers are optimized for connecting to your database in serverless and edge environments.

Prisma ORM maintains the following serverless driver adapters:

Community maintained database driver adapters

You can also build your own driver adapter for the database you're using. The following is a list of community maintained driver adapters:

How to use driver adapters

To use this feature:

  1. Update the previewFeatures block in your schema to include the the driverAdapters Preview feature:

    generator client {
    provider = "prisma-client-js"
    previewFeatures = ["driverAdapters"]
    }
  2. Generate Prisma Client:

    npx prisma generate
  3. Refer to the following pages to learn more how to use the specific driver adapters with the specific database providers:

Driver adapters and custom output paths

Since Prisma 5.9.0, when using the driver adapters Preview feature along with a custom output path for Prisma Client, you cannot reference Prisma Client using a relative path.

Let's assume you had output in your Prisma schema set to ../src/generated/client:

generator client {
provider = "prisma-client-js"
output = "../src/generated/client"
}

What you should not do is reference that path relatively:

// what not to do!
import { PrismaClient } from './src/generated/client'
const client = new PrismaClient()

Instead, you will need to use a linked dependency.

npm
pnpm
yarn
$npm add db@./src/generated/client

Now you should be able to reference your generated client using db!

import { PrismaClient } from 'db'
const client = new PrismaClient()