goPGbase
goPGbase
PostgreSQL client

Unified PostgreSQL Client

Security-first Go library with fluent queries, constructor-injected adaptors, and production-grade observability for PostgreSQL-compatible databases.

🚀
100% Pure Go
🔒
Secure-first
📊
Observable
📜
MIT License
goPGbase demo

Quick Start

import "github.com/goozt/gopgbase"

opts := gopgbase.Options{
  Addr:     "localhost:5432",
  User:     "app",
  Password: "securepassword",
  Database: "myapp",
  Logger:   slog.Default(),
}

client := gopgbase.NewClient(opts)

err := client.
  Query("SELECT id, name FROM users WHERE tenant_id = ?").
  WithArgs("tenant-1").
  ScanAll(context.Background(), &users)

Core Features

🔗 Unified Client

Works with PostgreSQL, RDS, CockroachDB, YugabyteDB using one API.

💉 Dependency Injection

Constructor-injected logger, tracer, metrics for testability.

✨ Fluent Queries

Chainable SELECT, INSERT, UPDATE with auto parameterization.

📈 Production Ready

OpenTelemetry, slog, metrics out of the box.

Security-First

SQL-Safe by Default

All inputs parameterized, no string concatenation.

Pure Go

No CGO, minimal attack surface, easy to audit.

Connection Safeguards

Timeouts, circuit breakers, resource limits.

Get Involved

Open source contributions welcome! Add adaptors, query helpers, or observability integrations.

Open an Issue →