Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 17 additions & 0 deletions content/200-orm/050-overview/500-databases/500-sqlite.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading