PrismaP
Prisma4w ago
7 replies
VoidPointer

Can't use SQLIte in Nextjs

I have tried everything I can find on setting up Prisma ORM with a SQLite db. I use this to create basic Prisma artifacts, direct from the docs:
npx prisma init --datasource-provider sqlite --output ../generated/prisma

Then I add only the model to this to the generated prisma\schema.prisma:
generator client {
  provider = "prisma-client"
  output   = "../generated/prisma"
}

datasource db {
  provider = "sqlite"
}

model Post {
  id      String   @id @default(cuid())
  name    String
}

Even my
.env
is purely generated, with:
DATABASE_URL="file:./dev.db"

and the generated prisma.config.ts at root contains this:
// This file was generated by Prisma, and assumes you have installed the following:
// npm install --save-dev prisma dotenv
import "dotenv/config";
import { defineConfig } from "prisma/config";

export default defineConfig({
  schema: "prisma/schema.prisma",
  migrations: {
    path: "prisma/migrations",
  },
  datasource: {
    url: process.env["DATABASE_URL"],
  },
});


Yet when I run npx prisma migrate deploy, I get told
Loaded Prisma config from prisma.config.ts.

Loaded Prisma config from prisma.config.ts.


Prisma schema loaded from prisma\schema.prisma.
Datasource "db": SQLite database

Error: P1013: The provided database string is invalid. The scheme is not recognized in database URL. Please refer to the documentation in https://pris.ly/d/config-url for constructing a correct connection string.
I haven't included debug and logging as these seem to apply to Prisma Client, which I haven't even got to creating yet. The only change I've made to what the CLI prisma init generates is the Post model.
This page gives an overview of all Prisma config options available for use.
Reference documentation for the prisma config file | Prisma Documen...
Was this page helpful?