Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrepareAllQueries ¶
PrepareAllQueries executes a PREPARE statement for all pggen generated SQL queries in querier files. Typical usage is as the AfterConnect callback for pgxpool.Config
pgx will use the prepared statement if available. Calling PrepareAllQueries is an optional optimization to avoid a network round-trip the first time pgx runs a query if pgx statement caching is enabled.
Types ¶
type DBQuerier ¶
type DBQuerier struct {
// contains filtered or unexported fields
}
func NewQuerier ¶
func NewQuerier(conn genericConn) *DBQuerier
NewQuerier creates a DBQuerier that implements Querier. conn is typically *pgx.Conn, pgx.Tx, or *pgxpool.Pool.
func NewQuerierConfig ¶
func NewQuerierConfig(conn genericConn, cfg QuerierConfig) *DBQuerier
NewQuerierConfig creates a DBQuerier that implements Querier with the given config. conn is typically *pgx.Conn, pgx.Tx, or *pgxpool.Pool.
func (*DBQuerier) OutParams ¶
func (q *DBQuerier) OutParams(ctx context.Context) ([]OutParamsRow, error)
OutParams implements Querier.OutParams.
func (*DBQuerier) OutParamsBatch ¶
func (q *DBQuerier) OutParamsBatch(batch genericBatch)
OutParamsBatch implements Querier.OutParamsBatch.
func (*DBQuerier) OutParamsScan ¶
func (q *DBQuerier) OutParamsScan(results pgx.BatchResults) ([]OutParamsRow, error)
OutParamsScan implements Querier.OutParamsScan.
type OutParamsRow ¶
type Querier ¶
type Querier interface { OutParams(ctx context.Context) ([]OutParamsRow, error) // OutParamsBatch enqueues a OutParams query into batch to be executed // later by the batch. OutParamsBatch(batch genericBatch) // OutParamsScan scans the result of an executed OutParamsBatch query. OutParamsScan(results pgx.BatchResults) ([]OutParamsRow, error) }
Querier is a typesafe Go interface backed by SQL queries.
Methods ending with Batch enqueue a query to run later in a pgx.Batch. After calling SendBatch on pgx.Conn, pgxpool.Pool, or pgx.Tx, use the Scan methods to parse the results.
type QuerierConfig ¶
type QuerierConfig struct { // DataTypes contains pgtype.Value to use for encoding and decoding instead // of pggen-generated pgtype.ValueTranscoder. // // If OIDs are available for an input parameter type and all of its // transitive dependencies, pggen will use the binary encoding format for // the input parameter. DataTypes []pgtype.DataType }