Skip to Content
ClientsDriversGo (PostgreSQL)

Connect from a Go Application

New Go applications should use Kubling’s official gRPC SDK. It supports Engine sessions, typed results, statements and transactions without PostgreSQL compatibility.

This page covers the PostgreSQL compatibility option for applications that specifically require a SQL driver. Kubling does not provide a Go driver for its native protocol; use pgx  to connect through an enabled pgProtocol listener.

Example:

package main import ( "context" "fmt" "log" "github.com/jackc/pgx/v4" ) func main() { // Connection string connStr := "postgres://sa:sa@localhost:35432/MyVDB" // Connect to the PostgreSQL database conn, err := pgx.Connect(context.Background(), connStr) if err != nil { log.Fatalf("Unable to connect to database: %v\n", err) } defer conn.Close(context.Background()) fmt.Println("Connected to Kubling!") rows, err := conn.Query(context.Background(), `SELECT identifier, org, repo from github.GITHUB_CODE_REPO_COLLABORATOR where repo in ('kubling-samples');`) if err != nil { log.Fatalf("Unable to query table: %v\n", err) } defer rows.Close() for rows.Next() { var identifier, org, repo string err = rows.Scan(&identifier, &org, &repo) if err != nil { log.Fatalf("Unable to scan row: %v\n", err) } fmt.Printf("ID: %s, Org: %s, Repo: %s\n", identifier, org, repo) } }
Last updated on