# Database drivers

## Default built-in drivers[​](#default-built-in-drivers "Direct link to Default built-in drivers")

One of Prisma Client's components is the [Query Engine](/docs/orm/more/under-the-hood/engines.md) (which is implemented in Rust). The Query Engine is responsible for transforming Prisma Client queries into SQL statements. It connects to your database via TCP using built-in drivers that don't require additional setup.

note

As of Prisma ORM 7, the query compiler (client engine) is the default, which means Prisma Client is generated without a Rust-based query engine binary. This provides better performance and developer experience. Learn more [here](/docs/orm/prisma-client/setup-and-configuration/no-rust-engine.md).

In Prisma ORM 7, the default generator configuration is:

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

Note that [driver adapters](/docs/orm/overview/databases/database-drivers.md#driver-adapters) are required when using the query compiler.

You can [read about the performance and DX improvements](https://www.prisma.io/blog/prisma-orm-without-rust-latest-performance-benchmarks) of this change on our blog.

![Query flow from the user application to the database with Prisma Client](/docs/assets/images/qe-query-execution-flow-2ee23fbefbd8c8cd57ddf0486b81817c.png)

## Driver adapters[​](#driver-adapters "Direct link to 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](/docs/assets/images/qe-query-engine-adapter-6e229f05859cb5a80c14c36889ce010f.png)

There are two different types of driver adapters:

* [Database driver adapters](#database-driver-adapters)
* [Serverless driver adapters](#serverless-driver-adapters)

> **Note**: Driver adapters enable [edge deployments](/docs/orm/prisma-client/deployment/edge/overview.md) of applications that use Prisma ORM.

### Database driver adapters[​](#database-driver-adapters "Direct link to 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 adapters for the following drivers:

* PostgreSQL
  <!-- -->
  * [`pg`](/docs/orm/overview/databases/postgresql.md#using-the-node-postgres-driver)

* Prisma Postgres
  <!-- -->
  * [`@prisma/adapter-ppg`](/docs/postgres/database/serverless-driver.md#use-with-prisma-orm)

* MySQL/MariaDB
  <!-- -->
  * [`mariadb`](/docs/orm/overview/databases/mysql.md#using-the-mariadb-driver)

* SQLite

  <!-- -->

  * [`better-sqlite3`](/docs/orm/overview/databases/sqlite.md#using-the-better-sqlite3-driver)
  * [`libSQL`](/docs/orm/overview/databases/turso.md#how-to-connect-and-query-a-turso-database) (Turso)

* MS SQL Server
  <!-- -->
  * [`node-mssql`](/docs/orm/overview/databases/sql-server.md#using-the-node-mssql-driver)

### Serverless driver adapters[​](#serverless-driver-adapters "Direct link to 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:

* [Prisma Postgres](/docs/postgres/database/serverless-driver.md#use-with-prisma-orm)
* [Neon](/docs/orm/overview/databases/neon.md#how-to-use-neons-serverless-driver-with-prisma-orm) (and Vercel Postgres)
* [PlanetScale](/docs/orm/overview/databases/planetscale.md#how-to-use-the-planetscale-serverless-driver-with-prisma-orm-preview)
* [Cloudflare D1](/docs/orm/overview/databases/cloudflare-d1.md)

### Community-maintained database driver adapters[​](#community-maintained-database-driver-adapters "Direct link to 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:

* [TiDB Cloud Serverless Driver](https://github.com/tidbcloud/prisma-adapter)
* [PGlite - Postgres in WASM](https://github.com/lucasthevenet/pglite-utils/tree/main/packages/prisma-adapter)

## How to use driver adapters[​](#how-to-use-driver-adapters "Direct link to How to use driver adapters")

Refer to the following pages to learn more about how to use the specific driver adapters with the specific database providers:

* [PostgreSQL](/docs/orm/overview/databases/postgresql.md#using-the-node-postgres-driver)
* [Prisma Postgres](/docs/postgres/database/serverless-driver.md#use-with-prisma-orm)
* [MySQL/MariaDB](/docs/orm/overview/databases/mysql.md#using-the-mariadb-driver)
* [MS SQL Server](/docs/orm/overview/databases/sql-server.md#using-the-node-mssql-driver)
* [Neon](/docs/orm/overview/databases/neon.md#how-to-use-neons-serverless-driver-with-prisma-orm)
* [PlanetScale](/docs/orm/overview/databases/planetscale.md#how-to-use-the-planetscale-serverless-driver-with-prisma-orm-preview)
* [Turso](/docs/orm/overview/databases/turso.md#how-to-connect-and-query-a-turso-database)
* [Cloudflare D1](/docs/orm/overview/databases/cloudflare-d1.md)

## Notes about using driver adapters[​](#notes-about-using-driver-adapters "Direct link to Notes about using driver adapters")

### New driver adapters API in v6.6.0[​](#new-driver-adapters-api-in-v660 "Direct link to New driver adapters API in v6.6.0")

In [v6.6.0](https://github.com/prisma/prisma/releases/tag/6.6.0), we introduced a simplified version for instantiating Prisma Client when using driver adapters. You now don't need to create an instance of the driver/client to pass to a driver adapter, instead you can just create the driver adapter directly (and pass the driver's options to it if needed).

Here is an example using the `@prisma/adapter-libsql` adapter:

#### Before 6.6.0[​](#before-660 "Direct link to Before 6.6.0")

Earlier versions of Prisma ORM required you to first instantiate the driver itself, and then use that instance to create the Prisma driver adapter. Here is an example using the `@libsql/client` driver for LibSQL:

```
import { createClient } from '@libsql/client'
import { PrismaLibSQL } from '@prisma/adapter-libsql'
import { PrismaClient } from '../prisma/generated/client'

// Old way of using driver adapters (before 6.6.0)
const driver = createClient({
  url: env.LIBSQL_DATABASE_URL,
  authToken: env.LIBSQL_DATABASE_TOKEN,
})
const adapter = new PrismaLibSQL(driver)

const prisma = new PrismaClient({ adapter })
```

#### 6.6.0 and later[​](#660-and-later "Direct link to 6.6.0 and later")

As of the 6.6.0 release, you instantiate the driver adapter *directly* with the options of your preferred JS-native driver.:

```
import { PrismaLibSQL } from '@prisma/adapter-libsql'
import { PrismaClient } from '../generated/prisma/client'

const adapter = new PrismaLibSQL({
  url: env.LIBSQL_DATABASE_URL,
  authToken: env.LIBSQL_DATABASE_TOKEN,
})

const prisma = new PrismaClient({ adapter })
```

### Driver adapters and database connection configuration[​](#driver-adapters-and-database-connection-configuration "Direct link to Driver adapters and database connection configuration")

In Prisma ORM 7, the database connection URL is configured in [`prisma.config.ts`](/docs/orm/reference/prisma-config-reference.md). However, when using a driver adapter, the connection string needs to be provided in your *application code* when the driver adapter is set up initially.

Here is how this is done for the `pg` driver and the `@prisma/adapter-pg` adapter:

```
import 'dotenv/config'
import { PrismaClient } from '../generated/prisma/client'
import { PrismaPg } from '@prisma/adapter-pg'

const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL })
const prisma = new PrismaClient({ adapter })
```

See the docs for the driver adapter you're using for concrete setup instructions.

Tuning pool sizes, timeouts, or other connection parameters

See the [connection pool guide](/docs/orm/prisma-client/setup-and-configuration/databases-connections/connection-pool.md) for the Prisma ORM v7 driver adapter defaults and how they map from Prisma ORM v6 URL parameters.

Prisma timeouts

Prisma ORM also has its own configurable timeouts that are separate from the database driver timeouts. If you see a timeout error and are unsure whether it comes from the driver or from Prisma Client, see the [Prisma Client timeouts and transaction options documentation](/docs/orm/prisma-client/queries/transactions.md#transaction-options).

### Driver adapters and custom output paths[​](#driver-adapters-and-custom-output-paths "Direct link to Driver adapters and custom output paths")

In Prisma ORM 7, the recommended approach is to use a custom output path for Prisma Client. The default output path is `../generated/prisma`.

Let's assume you have `output` in your Prisma schema set to `../generated/prisma`:

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

You can reference Prisma Client using a relative path from your application code:

```
import { PrismaClient } from '../generated/prisma/client'

const client = new PrismaClient()
```

Alternatively, you can use a linked dependency for cleaner imports.

* npm
  **
  npm
* pnpm
* yarn

```
npm add db@./generated/prisma
```

```
pnpm add db@link:./generated/prisma
```

```
yarn add db@link:./generated/prisma
```

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

```
import { PrismaClient } from 'db'

const client = new PrismaClient()
```

### Driver adapters and specific frameworks[​](#driver-adapters-and-specific-frameworks "Direct link to Driver adapters and specific frameworks")

#### Nuxt[​](#nuxt "Direct link to Nuxt")

Using a driver adapter with [Nuxt](https://nuxt.com/) to deploy to an edge function environment does not work out of the box, but adding the `nitro.experimental.wasm` configuration option fixes that:

```
export default defineNuxtConfig({
  // ...
  nitro: {
    // ...
    experimental: {
      wasm: true,
    },
  },
  // ...
})
```

### Driver adapters and TypedSQL[​](#driver-adapters-and-typedsql "Direct link to Driver adapters and TypedSQL")

[TypedSQL](/docs/orm/prisma-client/using-raw-sql/typedsql.md) lets you write fully type-safe SQL queries that integrate directly with Prisma Client. This feature is useful if you want the flexibility of writing SQL while still benefiting from Prisma's type-safety.

You can also use driver adapters together with TypedSQL to connect through JavaScript database drivers. TypedSQL works with all supported driver adapters except `@prisma/adapter-better-sqlite3`. For SQLite support, use [`@prisma/adapter-libsql`](https://www.npmjs.com/package/@prisma/adapter-libsql) instead.
