How can I connect to a postgres database?

I'm trying to connect to my postgres database through node-postgres but it fails because of required node dependencies.
import { PRIVATE_DATABASE_URL } from '$env/static/private';
import pg from "pg";
import { drizzle } from "drizzle-orm/node-postgres";
import * as schema from '$lib/schema/schema';
import * as relations from '$lib/schema/relations';

const connectionString = PRIVATE_DATABASE_URL;
const pool = new pg.Pool({
connectionString: encodeURI(connectionString),
});
const db = drizzle(pool, {
schema: { ...schema, ...relations},
});

export default db;
import { PRIVATE_DATABASE_URL } from '$env/static/private';
import pg from "pg";
import { drizzle } from "drizzle-orm/node-postgres";
import * as schema from '$lib/schema/schema';
import * as relations from '$lib/schema/relations';

const connectionString = PRIVATE_DATABASE_URL;
const pool = new pg.Pool({
connectionString: encodeURI(connectionString),
});
const db = drizzle(pool, {
schema: { ...schema, ...relations},
});

export default db;
According to this https://orm.drizzle.team/docs/quick-postgresql/supabase#usage-with-cloudflare-workers. It should work in a worker. I'm just not sure why it's not working for my sveltekit pages deployment.
Supabase - DrizzleORM
Drizzle ORM | %s
4 Replies
Dinh · divn.dev
Dinh · divn.dev14mo ago
I have same issue
Dr. Unstable
Dr. UnstableOP14mo ago
I ended up just switching to vercel. They support node-postgres.
은성
은성14mo ago
try neon, seems cool and free
은성
은성14mo ago
Neon
Drivers release Mar 08, 2023 - Neon
Fixes & improvements - Released a new version of the Neon serverless driver (v0.2.6), which allows you to query data from Cloudflare Workers, Vercel Edge Functi...
Want results from more Discord servers?
Add your server