Exec acquires a connection from the [Pool] and executes the given SQL. SQL can be either a prepared statement name or an SQL string. Arguments should be referenced positionally from the SQL string as $1, $2, etc. The acquired connection is returned to the pool when the [Pool.Exec] function returns.
(ctx context.Context, sql string, arguments ...any)
| 725 | // Arguments should be referenced positionally from the SQL string as $1, $2, etc. |
| 726 | // The acquired connection is returned to the pool when the [Pool.Exec] function returns. |
| 727 | func (p *Pool) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error) { |
| 728 | c, err := p.Acquire(ctx) |
| 729 | if err != nil { |
| 730 | return pgconn.CommandTag{}, err |
| 731 | } |
| 732 | defer c.Release() |
| 733 | |
| 734 | return c.Exec(ctx, sql, arguments...) |
| 735 | } |
| 736 | |
| 737 | // Query acquires a connection and executes a query that returns [pgx.Rows]. |
| 738 | // Arguments should be referenced positionally from the SQL string as $1, $2, etc. |