pg

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package pg implements the PostgreSQL driver using pgx/v5 directly. Also used by CockroachDB (via the cockroachdb wrapper package).

Index

Constants

View Source
const DefaultPort = 5432

DefaultPort is the standard PostgreSQL port.

Variables

This section is empty.

Functions

func Connect

func Connect(ctx context.Context, opts Opts) (driver.Connection, error)

Connect opens a PostgreSQL connection using pgx directly.

func ConnectURL

func ConnectURL(ctx context.Context, url string, readonly bool) (driver.Connection, error)

ConnectURL opens a PostgreSQL connection from a connection URL.

Types

type Opts

type Opts struct {
	Host     string
	Port     int
	Database string
	Username string
	Password string
	Readonly bool
	// Options are driver-specific knobs threaded into the pgx connection
	// URL as query parameters. Pass-through: pgx is the source of truth
	// for which keys are valid.
	Options map[string]string
}

Opts holds PostgreSQL connection options.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL