Prisma 7 + SQLite via better-sqlite3 adapter: working versions (tested 2026-10-15)
Prisma Client 7 with the better-sqlite3 driver adapter, schema push and relational queries on a local SQLite file.
passed1 passed · 0 failed2026-10-15 12:54 UTC- Status
- passed
- Last passed
- 2026-10-15 12:54 UTC
- Tests
- 1 / 1
- Language
- TypeScript
- Runtime
- node v22.23.3
npm install --no-audit --no-fund && npx prisma db push && npx prisma generate npm test
node v22.23.3 linux 6.17.0-1022-azure x64 runner: github-actions 38737894352
The code
Exactly the files that passed. Your agent can pull them with get_recipe("prisma-sqlite-adapter") (install), or see them on GitHub.
{
"name": "prisma-sqlite-adapter",
"private": true,
"type": "module",
"scripts": {
"test": "node --import tsx --test test/*.test.ts"
},
"dependencies": {
"@prisma/client": "7.10.0",
"@prisma/adapter-better-sqlite3": "7.10.0"
},
"devDependencies": {
"tsx": "4.23.15",
"@types/node": "24.19.2",
"prisma": "7.10.0"
}
}
generator client {
provider = "prisma-client"
output = "../src/generated/prisma"
}
datasource db {
provider = "sqlite"
}
model User {
id Int @id @default(autoincrement())
email String @unique
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
title String
author User @relation(fields: [authorId], references: [id])
authorId Int
}
import { defineConfig } from "prisma/config";
export default defineConfig({
schema: "prisma/schema.prisma",
datasource: { url: "file:./test.db" },
});
import { PrismaBetterSqlite3 } from "@prisma/adapter-better-sqlite3";
import { PrismaClient } from "./generated/prisma/client.ts";
export function createClient(url = "file:./test.db") {
return new PrismaClient({ adapter: new PrismaBetterSqlite3({ url }) });
}
import { test } from "node:test";
import assert from "node:assert/strict";
import { createClient } from "../src/db.ts";
test("create user with posts and query relation", async () => {
const prisma = createClient();
await prisma.post.deleteMany();
await prisma.user.deleteMany();
await prisma.user.create({ data: { email: "[email protected]", posts: { create: [{ title: "one" }, { title: "two" }] } } });
const user = await prisma.user.findUnique({ where: { email: "[email protected]" }, include: { posts: true } });
assert.equal(user?.posts.length, 2);
await prisma.$disconnect();
});
Connect to ProvenPin
Add the free MCP server so your agent can pull this recipe and others like it. Same setup as the docs.
claude mcp add --transport http provenpin https://mcp.provenpin.com/mcp
{ "mcpServers": { "provenpin": { "url": "https://mcp.provenpin.com/mcp" } } }{ "servers": { "provenpin": { "type": "http", "url": "https://mcp.provenpin.com/mcp" } } }{ "mcpServers": { "provenpin": { "serverUrl": "https://mcp.provenpin.com/mcp" } } }{ "mcpServers": { "provenpin": { "type": "streamableHttp", "url": "https://mcp.provenpin.com/mcp" } } }Any other MCP client: Streamable HTTP at https://mcp.provenpin.com/mcp. No API key, no signup.
Related stacks
Prisma 7 + SQLite: nested writes, interactive transactions and unique errors
Prisma Client 7 on SQLite (better-sqlite3 adapter): nested creates, an interactive $transaction that rolls back, and handling P2002 unique-constraint errors.
Drizzle ORM + better-sqlite3 CRUD
Typed schema, migrations-free table creation and CRUD with Drizzle on an in-memory SQLite database.
Kysely + better-sqlite3 typed queries
Type-safe SQL with Kysely on SQLite, including a schema migration, joins and a transaction.
Drizzle ORM + drizzle-zod validated inserts on SQLite
Generate Zod insert and select schemas from Drizzle tables with drizzle-zod, refine them, and validate input before inserting into SQLite.
All Prisma recipesAll SQLite recipesAll better-sqlite3 recipes