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 starv
(pool *pgxpool.Pool, opts ...OptionOpenDB)
| 235 | // required to avoid acquiring all the connections from the pgxpool and starving any direct users of the pgxpool. Note |
| 236 | // that closing the returned *sql.DB will not close the *pgxpool.Pool. |
| 237 | func OpenDBFromPool(pool *pgxpool.Pool, opts ...OptionOpenDB) *sql.DB { |
| 238 | c := GetPoolConnector(pool, opts...) |
| 239 | db := sql.OpenDB(c) |
| 240 | db.SetMaxIdleConns(0) |
| 241 | return db |
| 242 | } |
| 243 | |
| 244 | type connector struct { |
| 245 | pgx.ConnConfig |