pgx

package
v0.42.5 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	*pgx.Conn
}

Conn is similar to *pgx.Conn but implements [Queryer]

func NewConn

func NewConn(conn *pgx.Conn) Conn

NewConn wraps an *pgx.Conn and returns a type that implements [Queryer] This is useful when an existing *pgx.Conn is used in other places in the codebase

func (Conn) Begin

func (c Conn) Begin(ctx context.Context) (Tx, error)

Begin is similar to *pgxpool.Pool.Begin, but return a transaction that implements [Queryer]

func (Conn) BeginTx

func (c Conn) BeginTx(ctx context.Context, opts pgx.TxOptions) (Tx, error)

BeginTx is similar to *pgxpool.Pool.BeginTx, but return a transaction that implements [Queryer]

func (Conn) ExecContext

func (c Conn) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

ExecContext executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (Conn) QueryContext

func (c Conn) QueryContext(ctx context.Context, query string, args ...any) (scan.Rows, error)

QueryContext executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.

type Pool

type Pool struct {
	*pgxpool.Pool
}

Pool is similar to *pgxpool.Pool but implement [Queryer]

func New

func New(ctx context.Context, dsn string) (Pool, error)

New works just like pgxpool.New, but converts the returned *pgxpool.Pool to Pool

func NewPool

func NewPool(pool *pgxpool.Pool) Pool

NewPool wraps an *pgxpool.Pool and returns a type that implements [bob.Executor] but still retains the expected methods used by *pgxpool.Pool This is useful when an existing *pgxpool.Pool is used in other places in the codebase

func NewWithConfig

func NewWithConfig(ctx context.Context, config *pgxpool.Config) (Pool, error)

NewWithConfig works just like pgxpool.NewWithConfig, but converts the returned *pgxpool.Pool to Pool

func (Pool) Acquire

func (p Pool) Acquire(ctx context.Context) (PoolConn, error)

Acquire is similar to *pgxpool.Pool.Acquire but returns a connection that implement [Queryer]

func (*Pool) AcquireFunc

func (p *Pool) AcquireFunc(ctx context.Context, f func(PoolConn) error) error

AcquireFunc is similar to *pgxpool.Pool.AcquireFunc but uses a function that accepts a connection that implements [Queryer].

func (Pool) Begin

func (p Pool) Begin(ctx context.Context) (Tx, error)

Begin is similar to *pgxpool.Pool.Begin, but return a transaction that implements [Queryer]

func (Pool) BeginTx

func (p Pool) BeginTx(ctx context.Context, opts pgx.TxOptions) (Tx, error)

BeginTx is similar to *pgxpool.Pool.BeginTx, but return a transaction that implements [Queryer]

func (Pool) ExecContext

func (p Pool) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

ExecContext executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (Pool) QueryContext

func (p Pool) QueryContext(ctx context.Context, query string, args ...any) (scan.Rows, error)

QueryContext executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.

type PoolConn

type PoolConn struct {
	*pgxpool.Conn
}

Conn is similar to *pgx.Conn but implements [Queryer]

func NewPoolConn

func NewPoolConn(conn *pgxpool.Conn) PoolConn

NewConn wraps an *pgx.Conn and returns a type that implements [Queryer] This is useful when an existing *pgx.Conn is used in other places in the codebase

func (PoolConn) Begin

func (c PoolConn) Begin(ctx context.Context) (Tx, error)

Begin is similar to *pgxpool.Pool.Begin, but return a transaction that implements [Queryer]

func (PoolConn) BeginTx

func (c PoolConn) BeginTx(ctx context.Context, opts pgx.TxOptions) (Tx, error)

BeginTx is similar to *pgxpool.Pool.BeginTx, but return a transaction that implements [Queryer]

func (PoolConn) ExecContext

func (c PoolConn) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

ExecContext executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (PoolConn) QueryContext

func (c PoolConn) QueryContext(ctx context.Context, query string, args ...any) (scan.Rows, error)

QueryContext executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.

type Tx

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

Tx is similar to *pgx.Tx but implements [Queryer]

func NewTx

func NewTx(tx pgx.Tx, cancel context.CancelFunc) Tx

NewTx wraps an pgx.Tx and returns a type that implements [Queryer] but still retains the expected methods used by pgx.Tx This is useful when an existing pgx.Tx is used in other places in the codebase the cancel function is optional, but if provided, it will be called when Commit or Rollback is called

func (Tx) Begin

func (t Tx) Begin(ctx context.Context) (pgx.Tx, error)

Begin implements pgx.Tx.

func (Tx) Commit

func (t Tx) Commit(ctx context.Context) error

Commit implements bob.Transaction.

func (Tx) Conn

func (t Tx) Conn() *pgx.Conn

Conn implements pgx.Tx.

func (Tx) CopyFrom

func (t Tx) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)

CopyFrom implements pgx.Tx.

func (Tx) Exec

func (t Tx) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)

Exec implements pgx.Tx.

func (Tx) ExecContext

func (t Tx) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

ExecContext executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (Tx) LargeObjects

func (t Tx) LargeObjects() pgx.LargeObjects

LargeObjects implements pgx.Tx.

func (Tx) Prepare

func (t Tx) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error)

Prepare implements pgx.Tx.

func (Tx) Query

func (t Tx) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error)

Query implements pgx.Tx.

func (Tx) QueryContext

func (t Tx) QueryContext(ctx context.Context, query string, args ...any) (scan.Rows, error)

QueryContext executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.

func (Tx) QueryRow

func (t Tx) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row

QueryRow implements pgx.Tx.

func (Tx) Rollback

func (t Tx) Rollback(ctx context.Context) error

Rollback implements bob.Transaction.

func (Tx) SendBatch

func (t Tx) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults

SendBatch implements pgx.Tx.

Jump to

Keyboard shortcuts

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