MCPcopy
hub / github.com/jackc/pgx / Query

Method Query

pgxpool/pool.go:747–760  ·  view source on GitHub ↗

Query acquires a connection and executes a query that returns [pgx.Rows]. Arguments should be referenced positionally from the SQL string as $1, $2, etc. See [pgx.Rows] documentation to close the returned [pgx.Rows] and return the acquired connection to the [Pool]. If there is an error, the returne

(ctx context.Context, sql string, args ...any)

Source from the content-addressed store, hash-verified

745// [pgx.QueryResultFormatsByOID] may be used as the first args to control exactly how the query is executed. This is rarely
746// needed. See the documentation for those types for details.
747func (p *Pool) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error) {
748 c, err := p.Acquire(ctx)
749 if err != nil {
750 return errRows{err: err}, err
751 }
752
753 rows, err := c.Query(ctx, sql, args...)
754 if err != nil {
755 c.Release()
756 return errRows{err: err}, err
757 }
758
759 return c.getPoolRows(rows), nil
760}
761
762// QueryRow acquires a connection and executes a query that is expected
763// to return at most one row ([pgx.Row]). Errors are deferred until [pgx.Row]'s

Callers

nothing calls this directly

Calls 4

AcquireMethod · 0.95
ReleaseMethod · 0.80
QueryMethod · 0.65
getPoolRowsMethod · 0.45

Tested by

no test coverage detected