Skip to content
bun:sqlite/ prisma adapter

Getting started

Install

bun add prisma-sqlite-bun-adapter
bun add -d prisma

Define a schema

Prisma 7 schemas do not carry a connection URL. The datasource declares only the provider:

// schema.prisma
generator client {
  provider = "prisma-client"
  output   = "./generated"
  runtime  = "bun"
}

datasource db {
  provider = "sqlite"
}

Setting runtime = "bun" tells the generator to emit the Bun build of the client.

Configure the CLI

Connection details for CLI commands live in prisma.config.ts:

// prisma.config.ts
import { defineConfig } from 'prisma/config'

export default defineConfig({
  schema: 'schema.prisma',
  datasource: { url: 'file:./dev.db' },
})

Create the database

bunx prisma migrate dev --name init

This creates dev.db, writes a migration, and generates the client. See Migrations for what the CLI does and does not route through the adapter.

Query

import { PrismaBunSQLite } from 'prisma-sqlite-bun-adapter'
import { PrismaClient } from './generated/client'

const adapter = new PrismaBunSQLite({ url: 'file:./dev.db' })
const prisma = new PrismaClient({ adapter })

const user = await prisma.user.create({
  data: { email: 'ada@example.com', name: 'Ada' },
})

console.log(await prisma.user.findMany())

Run it with Bun:

bun run index.ts

Using an in-memory database

Useful for unit tests, where each test can start from a clean database:

const adapter = new PrismaBunSQLite({ url: ':memory:' })

An in-memory database starts empty, so apply your schema before querying — either by replaying your migration SQL or with db push against a temporary file.

A note on foreign keys

SQLite leaves foreign key enforcement off by default, which means relations declared in your Prisma schema are not enforced by the database. Turn it on with the PRAGMA defaults:

const adapter = new PrismaBunSQLite({ url: 'file:./dev.db' }, { pragmas: {} })

See Configuration for the full set.