X
Xata2w ago
Rittam

Connect xata-db with encore.dev

tried this connection in the db>index.ts file but wasn't able to figure out.
No description
2 Replies
Rittam
RittamOP2w ago
figured it out. import pg from "pg"; import { drizzle } from "drizzle-orm/node-postgres"; import { env } from "@/env"; if (!env.XATA_DATABASE_URL) { throw new Error("❌ XATA_DATABASE_URL is not set."); } const pool = new pg.Pool({ connectionString: env.XATA_DATABASE_URL as string, max: 20, }); export const db = drizzle(pool); pool .connect() .then(() => console.log("✅ Connected to Xata Postgres!")) .catch((err) => console.error("❌ Connection error:", err)); export default db;
cmck
cmck2w ago
Hi Rittam, sorry for the delay getting back to you. Glad to hear you got it working! 👍

Did you find this page helpful?