shad-go/lectures/07-sql/open/pgx.go
2020-04-09 14:15:54 +03:00

17 lines
264 B
Go

package open
import (
"context"
"log"
"github.com/jackc/pgx/v4"
)
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)
}