diff --git a/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx b/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx index 550910a297..b5866d0cff 100644 --- a/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx +++ b/content/100-getting-started/02-prisma-orm/100-quickstart/200-sqlite.mdx @@ -210,6 +210,24 @@ const prisma = new PrismaClient({ adapter }); export { prisma }; ``` +:::tip Using SQLite with Bun +When targeting Bun, use the `@prisma/adapter-libsql` adapter instead of `@prisma/adapter-better-sqlite3`. Bun doesn’t support the native SQLite driver that `better-sqlite3` relies on (see the [`node:sqlite` reference](https://bun.com/reference/node/sqlite)). Instantiate Prisma Client like so: + +```ts +import 'dotenv/config'; +import { PrismaLibSql } from '@prisma/adapter-libsql'; +import { PrismaClient } from '../generated/prisma/client'; + +const adapter = new PrismaLibSql({ + url: process.env.DATABASE_URL ?? '', +}); + +const prisma = new PrismaClient({ adapter }); + +export { prisma }; +``` +::: + ## 8. Write your first query Create a `script.ts` file to test your setup: diff --git a/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx b/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx index fbdafa6a4d..506ddbbc4c 100644 --- a/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx +++ b/content/100-getting-started/02-prisma-orm/200-add-to-existing-project/200-sqlite.mdx @@ -175,6 +175,25 @@ const prisma = new PrismaClient({ adapter }); export { prisma }; ``` +:::tip Using SQLite with Bun +Bun doesn't support the native SQLite driver that `better-sqlite3` relies on (see the [`node:sqlite` reference](https://bun.com/reference/node/sqlite)). When targeting Bun, use the `@prisma/adapter-libsql` adapter instead: + +```ts +import 'dotenv/config'; +import { PrismaLibSql } from '@prisma/adapter-libsql'; +import { PrismaClient } from '../generated/prisma/client'; + +const adapter = new PrismaLibSql({ + url: process.env.DATABASE_URL ?? '', +}); + +const prisma = new PrismaClient({ adapter }); + +export { prisma }; +``` + +::: + ## 8. Query your database Now you can use Prisma Client to query your database. Create a `script.ts` file: diff --git a/content/200-orm/050-overview/500-databases/500-sqlite.mdx b/content/200-orm/050-overview/500-databases/500-sqlite.mdx index 6235b5d18c..6d40fe51ec 100644 --- a/content/200-orm/050-overview/500-databases/500-sqlite.mdx +++ b/content/200-orm/050-overview/500-databases/500-sqlite.mdx @@ -66,6 +66,23 @@ const adapter = new PrismaBetterSqlite3({ const prisma = new PrismaClient({ adapter }) ``` +:::tip Using SQLite with Bun +When running Prisma Client on Bun, use the `@prisma/adapter-libsql` driver adapter. Bun doesn't support the native SQLite driver that `better-sqlite3` relies on (see the [`node:sqlite` reference](https://bun.com/reference/node/sqlite)). Instantiate the adapter and pass it to `PrismaClient`: + +```ts +import { PrismaClient } from '../prisma/generated/client'; +import { PrismaLibSql } from '@prisma/adapter-libsql'; + +const adapter = new PrismaLibSql({ + url: process.env.DATABASE_URL ?? '', +}); + +const prisma = new PrismaClient({ adapter }); + +export default prisma; +``` +::: + ### 3. Configure timestamp format for backward compatibility When using driver adapters with SQLite, you can configure how `DateTime` values are stored in the database using the `timestampFormat` option.