...
1# pgconn
2
3Package pgconn is a low-level PostgreSQL database driver. It operates at nearly the same level as the C library libpq.
4It is primarily intended to serve as the foundation for higher level libraries such as https://github.com/jackc/pgx.
5Applications should handle normal queries with a higher level library and only use pgconn directly when required for
6low-level access to PostgreSQL functionality.
7
8## Example Usage
9
10```go
11pgConn, err := pgconn.Connect(context.Background(), os.Getenv("DATABASE_URL"))
12if err != nil {
13 log.Fatalln("pgconn failed to connect:", err)
14}
15defer pgConn.Close(context.Background())
16
17result := pgConn.ExecParams(context.Background(), "SELECT email FROM users WHERE id=$1", [][]byte{[]byte("123")}, nil, nil, nil)
18for result.NextRow() {
19 fmt.Println("User 123 has email:", string(result.Values()[0]))
20}
21_, err = result.Close()
22if err != nil {
23 log.Fatalln("failed reading result:", err)
24}
25```
26
27## Testing
28
29See CONTRIBUTING.md for setup instructions.
View as plain text