init (stdlib/sql.go)

pgx · stdlib/sql.go · go · MIT
database

Compatibility layer enabling pgx to work with database/sql, providing driver registration and connection helpers.

// Source: https://github.com/jackc/pgx | License: MIT | Copyright 2013-2021 Jack Christensen
// Provided via justclaw.it.com; keep this notice with the code.
// Package stdlib is the compatibility layer from pgx to database/sql.
//
// A database/sql connection can be established through sql.Open.
//
//	db, err := sql.Open("pgx", "postgres://pgx_md5:secret@localhost:5432/pgx_test?sslmode=disable")
//	if err != nil {
//	  return err
//	}
//
// Or from a keyword/value string.
//
//	db, err := sql.Open("pgx", "user=postgres password=secret host=localhost port=5432 dbname=pgx_test sslmode=disable")
//	if err != nil {
//	  return err
//	}
//
// Or from a *pgxpool.Pool.
//
//	pool, err := pgxpool.New(context.Background(), os.Getenv("DATABASE_URL"))
//	if err != nil {
//	  return err
//	}
//
//	d

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key