2
0

Improve documentation

This commit is contained in:
Jack Christensen
2019-06-22 16:54:10 -05:00
parent 731f1eadf5
commit d2440c7fe6
3 changed files with 30 additions and 3 deletions
+22 -2
View File
@@ -3,9 +3,29 @@
# pgconn
Package pgconn is a low-level PostgreSQL database driver.
Package pgconn is a low-level PostgreSQL database driver. It operates at nearly the same level is 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.
It is intended to serve as the foundation for the next generation of https://github.com/jackc/pgx.
## Example Usage
```go
pgConn, err := pgconn.Connect(context.Background(), os.Getenv("DATABASE_URL"))
if err != nil {
log.Fatalln("pgconn failed to connect:", err)
}
defer pgConn.Close()
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