func GetConnector(config pgx.ConnConfig, opts ...OptionOpenDB) driver.Connector
func GetDefaultDriver() driver.Driver
GetDefaultDriver returns the driver initialized in the init function and used when the pgx driver is registered.
func GetPoolConnector(pool *pgxpool.Pool, opts ...OptionOpenDB) driver.Connector
GetPoolConnector creates a new driver.Connector from the given *pgxpool.Pool. By using this be sure to set the maximum idle connections of the *sql.DB created with this connector to zero since they must be managed from the *pgxpool.Pool. This is required to avoid acquiring all the connections from the pgxpool and starving any direct users of the pgxpool.
func OpenDB(config pgx.ConnConfig, opts ...OptionOpenDB) *sql.DB
func OpenDBFromPool(pool *pgxpool.Pool, opts ...OptionOpenDB) *sql.DB
OpenDBFromPool creates a new *sql.DB from the given *pgxpool.Pool. Note that this method automatically sets the maximum number of idle connections in *sql.DB to zero, since they must be managed from the *pgxpool.Pool. This is required to avoid acquiring all the connections from the pgxpool and starving any direct users of the pgxpool.
func RandomizeHostOrderFunc(ctx context.Context, connConfig *pgx.ConnConfig) error
RandomizeHostOrderFunc is a BeforeConnect hook that randomizes the host order in the provided connConfig, so that a new host becomes primary each time. This is useful to distribute connections for multi-master databases like CockroachDB. If you use this you likely should set https://golang.org/pkg/database/sql/#DB.SetConnMaxLifetime as well to ensure that connections are periodically rebalanced across your nodes.
func RegisterConnConfig(c *pgx.ConnConfig) string
RegisterConnConfig registers a ConnConfig and returns the connection string to use with Open.
func UnregisterConnConfig(connStr string)
UnregisterConnConfig removes the ConnConfig registration for connStr.
type Conn struct {
// contains filtered or unexported fields
}
func (c *Conn) Begin() (driver.Tx, error)
func (c *Conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error)
func (c *Conn) CheckNamedValue(*driver.NamedValue) error
func (c *Conn) Close() error
func (c *Conn) Conn() *pgx.Conn
Conn returns the underlying *pgx.Conn
func (c *Conn) ExecContext(ctx context.Context, query string, argsV []driver.NamedValue) (driver.Result, error)
func (c *Conn) Ping(ctx context.Context) error
func (c *Conn) Prepare(query string) (driver.Stmt, error)
func (c *Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)
func (c *Conn) QueryContext(ctx context.Context, query string, argsV []driver.NamedValue) (driver.Rows, error)
func (c *Conn) ResetSession(ctx context.Context) error
type Driver struct {
// contains filtered or unexported fields
}
func (d *Driver) Open(name string) (driver.Conn, error)
func (d *Driver) OpenConnector(name string) (driver.Connector, error)
OptionOpenDB options for configuring the driver when opening a new db pool.
type OptionOpenDB func(*connector)
func OptionAfterConnect(ac func(context.Context, *pgx.Conn) error) OptionOpenDB
OptionAfterConnect provides a callback for after connect. Used only if db is opened with *pgx.ConnConfig.
func OptionBeforeConnect(bc func(context.Context, *pgx.ConnConfig) error) OptionOpenDB
OptionBeforeConnect provides a callback for before connect. It is passed a shallow copy of the ConnConfig that will be used to connect, so only its immediate members should be modified. Used only if db is opened with *pgx.ConnConfig.
func OptionResetSession(rs func(context.Context, *pgx.Conn) error) OptionOpenDB
OptionResetSession provides a callback that can be used to add custom logic prior to executing a query on the connection if the connection has been used before. If ResetSessionFunc returns ErrBadConn error the connection will be discarded.
type Rows struct {
// contains filtered or unexported fields
}
func (r *Rows) Close() error
func (r *Rows) ColumnTypeDatabaseTypeName(index int) string
ColumnTypeDatabaseTypeName returns the database system type name. If the name is unknown the OID is returned.
func (r *Rows) ColumnTypeLength(index int) (int64, bool)
ColumnTypeLength returns the length of the column type if the column is a variable length type. If the column is not a variable length type ok should return false.
func (r *Rows) ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool)
ColumnTypePrecisionScale should return the precision and scale for decimal types. If not applicable, ok should be false.
func (r *Rows) ColumnTypeScanType(index int) reflect.Type
ColumnTypeScanType returns the value type that can be used to scan types into.
func (r *Rows) Columns() []string
func (r *Rows) Next(dest []driver.Value) error
type Stmt struct {
// contains filtered or unexported fields
}
func (s *Stmt) Close() error
func (s *Stmt) Exec(argsV []driver.Value) (driver.Result, error)
func (s *Stmt) ExecContext(ctx context.Context, argsV []driver.NamedValue) (driver.Result, error)
func (s *Stmt) NumInput() int
func (s *Stmt) Query(argsV []driver.Value) (driver.Rows, error)
func (s *Stmt) QueryContext(ctx context.Context, argsV []driver.NamedValue) (driver.Rows, error)