Drizzle extension for Prisma
If you have an existing project with Prisma and want to try Drizzle or gradually adopt it, you can use our first-class extension that will add Drizzle API to your Prisma client. It will allow you to use Drizzle alongside your Prisma queries reusing your existing DB connection.
How to use
Install dependencies
You need to install Drizzle itself and a generator package that will create Drizzle schema from the Prisma schema.
npm
yarn
pnpm
bun
Update your Prisma schema
Add Drizzle generator to your Prisma schema. output
is the path where generated Drizzle schema TS files will be placed.
Generate Drizzle schema
Add Drizzle extension to your Prisma client
PostgreSQL
MySQL
SQLite
Run Drizzle queries via prisma.$drizzle
β¨
In order to use Drizzle query builder, you need references to Drizzle tables. You can import them from the output path that you specified in the generator config.
Limitations
- Relational queries are not supported due to a Prisma driver limitation. Because of it, Prisma unable to return query results in array format, which is required for relational queries to work.
- In SQLite,
.values()
(e.g.await db.select().from(table).values()
) is not supported, because of the same reason as above. - Prepared statements support is limited -
.prepare()
will only build the SQL query on Drizzle side, because there is no Prisma API for prepared queries.