shad-go/lectures/07-sql/open/pgx.go

18 lines
264 B
Go
Raw Normal View History

2020-04-09 11:15:34 +00:00
package open
2020-04-08 19:20:23 +00:00
import (
2020-04-09 11:15:34 +00:00
"context"
"log"
2020-04-08 19:20:23 +00:00
2020-04-09 11:15:34 +00:00
"github.com/jackc/pgx/v4"
2020-04-08 19:20:23 +00:00
)
2020-04-09 11:15:34 +00:00
func PGXOpen() {
ctx := context.Background()
conn, err := pgx.Connect(ctx, "postgres://pgx_md5:secret@localhost:5432/pgx_test")
if err != nil {
log.Fatal(err)
}
defer conn.Close(ctx)
}