Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/pgc4d/src/mod.ts>connectPg

A full-featured PostgreSQL Client for Deno
Latest
function connectPg
import { connectPg } from "https://deno.land/x/pgc4d@v1.3.6/src/mod.ts";

Opens a new connection to a PostgreSQL server and resolves to the connection (PgConn) once authenticated and ready to accept queries.

Usage:

const db1 = await connectPg('postgres://username:password@hostname/database', { ... more opts ... });
const db2 = await connectPg({ hostname, username, password, database });
const db3 = await connectPg({ transport: 'unix', path: '/foo/bar.sock', username });

Requirements:

  • tcp with ssl (default) requires --allow-net and --unstable
  • tcp without ssl requires --allow-net
  • unix requires --allow-read and --unstable

Parameters

url: string
optional
options: ConnectPgOptions

Returns

Promise<PgConn>