INNER CODE UNIT · TypeScript
connectPostgres
VityaSchel/lufin · backend/src/db/postgresql/index.ts:136
export async function connectPostgres(connectionString: string) {
console.log("Connecting to PostgreSQL...");
const pool = new Pool({ connectionString });
const client = drizzle({ client: pool });
const result = await client
.execute<{ current_database: string }>("SELECT current_database();")
.then((res) => res.rows[0]);
if (!result) throw new Error("Failed to get current database name");
console.log("Connected to PostgreSQL database", result.current_database);
return postgresqlDb(client, pool);
}