pgxdriver

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PgxDriver

type PgxDriver struct {
	// contains filtered or unexported fields
}

PgxDriver implements driver.Driver using a pgxpool connection pool.

func New

func New(ctx context.Context, dsn string, pc ...driver.PoolConfig) (*PgxDriver, error)

New creates a new PgxDriver by connecting to the given DSN. An optional PoolConfig overrides pool sizing/lifetime (DSN pool_* params still apply for fields left zero).

func NewLazy added in v0.5.0

func NewLazy(ctx context.Context, dsn string, pc ...driver.PoolConfig) (*PgxDriver, error)

NewLazy creates a PgxDriver without eagerly pinging the server. The pool is created immediately but connections are established on demand. Use this for read replicas where an initial connection failure should be surfaced at query time (and failed over) rather than preventing engine startup.

func (*PgxDriver) Begin

func (d *PgxDriver) Begin(ctx context.Context) (driver.Tx, error)

Begin starts a new database transaction with default options.

func (*PgxDriver) BeginTx

func (d *PgxDriver) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)

BeginTx starts a new database transaction with the given options.

func (*PgxDriver) Close

func (d *PgxDriver) Close()

Close shuts down the connection pool.

func (*PgxDriver) CopyFrom added in v0.5.0

func (d *PgxDriver) CopyFrom(ctx context.Context, table string, columns []string, rows [][]any) (int64, error)

CopyFrom performs a high-throughput bulk load via the pgx COPY protocol on a pooled connection. It implements driver.BulkCopier.

func (*PgxDriver) Exec

func (d *PgxDriver) Exec(ctx context.Context, sql string, args ...any) (int64, error)

Exec executes a statement and returns the number of affected rows.

func (*PgxDriver) Ping added in v0.5.0

func (d *PgxDriver) Ping(ctx context.Context) error

Ping verifies a working connection to the database.

func (*PgxDriver) Query

func (d *PgxDriver) Query(ctx context.Context, sql string, args ...any) (driver.Rows, error)

Query executes a query that returns multiple rows.

func (*PgxDriver) QueryRow

func (d *PgxDriver) QueryRow(ctx context.Context, sql string, args ...any) driver.Row

QueryRow executes a query that returns at most one row.

func (*PgxDriver) SendBatch added in v0.3.0

func (d *PgxDriver) SendBatch(ctx context.Context, items []driver.BatchItem) (driver.BatchResults, error)

SendBatch sends all queued queries in a single pipelined round-trip using the pgx batch protocol. Results must be read in order via the returned BatchResults before it is closed.

func (*PgxDriver) Stat added in v0.5.0

func (d *PgxDriver) Stat() driver.PoolStat

Stat returns a snapshot of the pgxpool connection pool.

Jump to

Keyboard shortcuts

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