Documentation
¶
Overview ¶
Package postgres connects github.com/go-rio/rio to PostgreSQL through the pgx driver's database/sql adapter.
The package is deliberately thin: it constructs a *rio.DB with the built-in rio.Postgres dialect and installs a precise error translator that maps *pgconn.PgError values onto rio's sentinel errors. All SQL grammar lives in the rio core; this module never shapes a query.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New wraps an existing *sql.DB in a *rio.DB with the Postgres dialect and this package's error translator. Use it when you bring your own pool: a *sql.DB you tuned yourself, or one derived from a pgxpool.Pool via stdlib.OpenDBFromPool.
Options are applied after the translator, so rio.WithErrorTranslator in opts replaces this package's translation if you need to.
func Open ¶
Open opens a PostgreSQL database via pgx's database/sql adapter and wraps it in a *rio.DB. The DSN is handed to pgx untouched, so both URL form (postgres://user:pass@host:5432/app) and keyword/value form (host=... user=... dbname=...) work, along with every pgx runtime parameter.
Open validates the DSN eagerly — pgx's database/sql adapter would otherwise surface a malformed DSN on the first query — but it does not connect; ping the underlying pool (db.Unwrap().PingContext) to verify connectivity. Pool tuning also happens on the *sql.DB returned by Unwrap — rio never replaces or configures the connection pool.
Types ¶
This section is empty.