Skip to content

Commit

Permalink
add doc for OpenDBFromPool
Browse files Browse the repository at this point in the history
  • Loading branch information
lzakharov authored and jackc committed Sep 9, 2023
1 parent f42824c commit b301530
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stdlib/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ func OpenDB(config pgx.ConnConfig, opts ...OptionOpenDB) *sql.DB {
return sql.OpenDB(c)
}

// 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 OpenDBFromPool(pool *pgxpool.Pool, opts ...OptionOpenDB) *sql.DB {
c := GetPoolConnector(pool, opts...)
db := sql.OpenDB(c)
Expand Down

0 comments on commit b301530

Please sign in to comment.