Reputation: 25
I'm having trouble connecting my Turso database with Prisma. I'm currently using Prisma version 5.17, and Turso supports Prisma from version 5.4 and up. However, I'm running into issues because Turso provides a URL for database connections, whereas Prisma's documentation seems to expect a file path when using SQLite.
In schema.prisma I have:
datasource db {
provider = "sqlite"
url = "file:./dev.db" // Works locally but not with Turso URL
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
}
//model {...(rest of the code)
I also have these in my auth.js file:
import { PrismaClient } from '@prisma/client'
import { PrismaLibSQL } from '@prisma/adapter-libsql'
import { createClient } from '@libsql/client'
const libsql = createClient({
url: `${process.env.TURSO_DATABASE_URL}`,
authToken: `${process.env.TURSO_AUTH_TOKEN}`,
})
const adapter = new PrismaLibSQL(libsql)
const prisma = new PrismaClient({ adapter })
How can I configure Prisma to connect to a Turso database when Turso provides a URL and Prisma expects a file path for SQLite? Is there a way to use Turso with Prisma in a manner consistent with Prisma’s expectations, or do I need to use a different approach or library?
Any guidance or suggestions would be greatly appreciated!
Upvotes: 0
Views: 382