Connect xata-db with encore.dev
tried this connection in the db>index.ts file but wasn't able to figure out.

2 Replies
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;
Hi Rittam, sorry for the delay getting back to you. Glad to hear you got it working! 👍