unable to query the database with the SQLite libsql adapter

Hey folks I'm using SQLite as my preferred choice for the database during the development I will replace it with Turso in production so I installed following dependencies @libsql/client @prisma/adapter-libsql and changed my code db export code from this
import { PrismaClient } from "@prisma/client";

const globalForPrisma = globalThis as unknown as {
db?: PrismaClient;
};

const DEV_ENV = process.env.NODE_ENV === "development";

export const db =
globalForPrisma.db ??
new PrismaClient({
log: DEV_ENV ? ["query", "error", "warn"] : ["error"]
});

if (DEV_ENV) globalForPrisma.db = db;
import { PrismaClient } from "@prisma/client";

const globalForPrisma = globalThis as unknown as {
db?: PrismaClient;
};

const DEV_ENV = process.env.NODE_ENV === "development";

export const db =
globalForPrisma.db ??
new PrismaClient({
log: DEV_ENV ? ["query", "error", "warn"] : ["error"]
});

if (DEV_ENV) globalForPrisma.db = db;
to this
import { createClient, type Client } from "@libsql/client";
import { PrismaLibSQL } from "@prisma/adapter-libsql";
import { PrismaClient } from "@prisma/client";

const globalForPrisma = globalThis as unknown as {
client?: Client;
};

const DEV_ENV = process.env.NODE_ENV === "development";

const client =
globalForPrisma.client ??
createClient({
url: process.env.DATABASE_URL,
authToken: process.env.DATABASE_AUTH_TOKEN,
});

if (DEV_ENV) globalForPrisma.client = client;

const adapter = new PrismaLibSQL(client);

export const db = new PrismaClient({ adapter, log: DEV_ENV ? ["query", "error", "warn"] : ["error"] });
import { createClient, type Client } from "@libsql/client";
import { PrismaLibSQL } from "@prisma/adapter-libsql";
import { PrismaClient } from "@prisma/client";

const globalForPrisma = globalThis as unknown as {
client?: Client;
};

const DEV_ENV = process.env.NODE_ENV === "development";

const client =
globalForPrisma.client ??
createClient({
url: process.env.DATABASE_URL,
authToken: process.env.DATABASE_AUTH_TOKEN,
});

if (DEV_ENV) globalForPrisma.client = client;

const adapter = new PrismaLibSQL(client);

export const db = new PrismaClient({ adapter, log: DEV_ENV ? ["query", "error", "warn"] : ["error"] });
and also enabled the previewFeatures: ["driverAdapter"] in the prisma schema now I can't query my database
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server