Skip to content

Files

Latest commit

33163ee · Jun 12, 2025

History

History

pgconn

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Dec 29, 2024
May 8, 2024
Oct 29, 2022
Oct 7, 2023
Jul 12, 2022
Oct 29, 2022
Jun 12, 2025
May 10, 2025
Feb 26, 2022
Feb 26, 2022
May 11, 2024
Jun 12, 2025
May 11, 2024
May 14, 2025
Jul 12, 2023
Jun 12, 2023
Jun 12, 2025
Jul 12, 2022
Oct 29, 2022
Mar 31, 2025

README.md

pgconn

Package pgconn is a low-level PostgreSQL database driver. It operates at nearly the same level as the C library libpq. It is primarily intended to serve as the foundation for higher level libraries such as https://github.com/jackc/pgx. Applications should handle normal queries with a higher level library and only use pgconn directly when required for low-level access to PostgreSQL functionality.

Example Usage

pgConn, err := pgconn.Connect(context.Background(), os.Getenv("DATABASE_URL"))
if err != nil {
	log.Fatalln("pgconn failed to connect:", err)
}
defer pgConn.Close(context.Background())

result := pgConn.ExecParams(context.Background(), "SELECT email FROM users WHERE id=$1", [][]byte{[]byte("123")}, nil, nil, nil)
for result.NextRow() {
	fmt.Println("User 123 has email:", string(result.Values()[0]))
}
_, err = result.Close()
if err != nil {
	log.Fatalln("failed reading result:", err)
}

Testing

See CONTRIBUTING.md for setup instructions.