Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
mention pgxpool in go and pgx guide
  • Loading branch information
seriousben committed Aug 7, 2025
commit 857a66025b5fad4f9fc07c3f7198ba45406e7d22
22 changes: 22 additions & 0 deletions docs/guides/using-go-and-pgx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,25 @@ pgx types directly.

fmt.Println(author.Name)
}

.. note::
For production applications, consider using pgxpool for connection pooling:

.. code-block:: go

import (
"github.com/jackc/pgx/v5/pgxpool"
"example.com/sqlc-tutorial/db"
)

func main() {
pool, err := pgxpool.New(context.Background(), os.Getenv("DATABASE_URL"))
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to create connection pool: %v\n", err)
os.Exit(1)
}
defer pool.Close()

q := db.New(pool)
// Use q the same way as with single connections
}
Loading