Skip to content

blueprint.provider.pgsql

Blueprint PostgreSQL client

The client uses the pgx library.

Using the client

The PostgreSQL client relies on a single DSN string:

{
  "clickhouse": {
    "dsn": "postgres://username:password@localhost:5432/database?sslmode=allow"
  }
}
package main

import (
    "fmt"
    "github.com/oddbit-project/blueprint/provider/pgsql"
    "log"
    "os"
)

func main() {
    pgConfig := pgsql.NewClientConfig()
    pgConfig.DSN = "postgres://username:password@localhost:5432/database?sslmode=allow"

    client, err := pgsql.NewClient(pgConfig)
    if err != nil {
        log.Fatal(err)
    }
    if err = client.Connect(); err != nil {
        log.Fatal(err)
    }
    defer client.Disconnect()

    // do stuff
}