src/mdx/get-started/postgresql/ConnectSupabase.mdx
import Callout from '@mdx/Callout.astro';
Create a index.ts file in the src directory and initialize the connection:
import { drizzle } from 'drizzle-orm'
async function main() {
const db = drizzle('postgres-js', process.env.DATABASE_URL);
}
main();
If you need a synchronous connection, you can use our additional connection API, where you specify a driver connection and pass it to the Drizzle instance.
import { drizzle } from 'drizzle-orm/postgres-js'
import postgres from 'postgres'
async function main() {
const client = postgres(process.env.DATABASE_URL)
const db = drizzle({ client });
}
main();
import { drizzle } from 'drizzle-orm/postgres-js'
import postgres from 'postgres'
async function main() {
// Disable prefetch as it is not supported for "Transaction" pool mode
const client = postgres(process.env.DATABASE_URL, { prepare: false })
const db = drizzle({ client });
}
main();