pgx/pgconn
Jack Christensen a95cfe5cc5 Fix connect with multiple hostnames when one can't be resolved
If multiple hostnames are provided and one cannot be resolved the others
should still be tried.

Longterm, it would be nice for the connect process to return a list of
errors rather than just one.

fixes https://github.com/jackc/pgx/issues/1464
2023-01-14 09:19:00 -06:00
..
internal/ctxwatch Bump module version to v5 2021-12-11 13:29:03 -06:00
README.md Improve testing / contributing instructions 2022-10-29 17:14:09 -05:00
auth_scram.go Merge remote-tracking branch 'pgconn/master' into v5-dev 2022-07-12 06:45:54 -05:00
benchmark_private_test.go Use string internally for CommandTag 2022-07-11 21:09:03 -05:00
benchmark_test.go pgconn and pgproto use same environment variable for tests as pgx 2022-10-29 13:23:25 -05:00
config.go Expose underlying pgconn GetSSLPassword support to pgx 2022-11-03 20:09:52 -05:00
config_test.go pgconn and pgproto use same environment variable for tests as pgx 2022-10-29 13:23:25 -05:00
defaults.go Make Chunkreader an internal implementation detail 2022-02-26 08:50:46 -06:00
defaults_windows.go Make Chunkreader an internal implementation detail 2022-02-26 08:50:46 -06:00
doc.go Add pipeline mode to pgconn 2022-07-02 21:48:16 -05:00
errors.go pgconn.Timeout() no longer considers `context.Canceled` as a timeout error. 2022-09-17 10:18:06 -05:00
errors_test.go Bump module version to v5 2021-12-11 13:29:03 -06:00
export_test.go Import to pgx main repo in pgconn subdir 2021-12-04 13:51:24 -06:00
helper_test.go Bump module version to v5 2021-12-11 13:29:03 -06:00
krb5.go Merge remote-tracking branch 'pgconn/master' into v5-dev 2022-07-12 06:45:54 -05:00
pgconn.go Fix connect with multiple hostnames when one can't be resolved 2023-01-14 09:19:00 -06:00
pgconn_private_test.go Use string internally for CommandTag 2022-07-11 21:09:03 -05:00
pgconn_stress_test.go pgconn and pgproto use same environment variable for tests as pgx 2022-10-29 13:23:25 -05:00
pgconn_test.go Use DefaultQueryExecMode in CopyFrom 2022-12-23 13:22:26 -06:00

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.