pgx is a PostgreSQL Driver fork from pgx, and add opengauss sha256 sasl support.
package main
import (
"context"
"fmt"
"os"
"github.com/Kseleven/pgx/v5"
)
func main() {
// urlExample := "postgres://username:password@localhost:5432/database_name"
conn, err := pgx.Connect(context.Background(), os.Getenv("DATABASE_URL"))
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to connect to database: %v\n", err)
os.Exit(1)
}
defer conn.Close(context.Background())
var name string
var weight int64
err = conn.QueryRow(context.Background(), "select name, weight from widgets where id=$1", 42).Scan(&name, &weight)
if err != nil {
fmt.Fprintf(os.Stderr, "QueryRow failed: %v\n", err)
os.Exit(1)
}
fmt.Println(name, weight)
}See the getting started guide for more information.
- Same as pgx Features, See the pgx Features for more information.
- Support opengauss
password_encryption_type=2sha256 algorithm, See the opengauss for more information.