modulepackage
0.10.0
Repository: https://github.com/neighborly/go-pghelpers.git
Documentation: pkg.go.dev
# README
go-pghelpers 
Golang helpers for Postgres.
Installation
go get github.com/neighborly/go-pghelpers
Usage
PostgresConfig
PostgresConfig
holds the information for postgres database connection. For example
var postgresConfig = pghelpers.PostgresConfig{
Host: "localhost",
Port: 5432,
Username: "postgres",
Password: "",
Database: "postgres",
}
Connect Postgres
pghelpers.ConnectPostgres
function returns db object and error if any. You can use pghelpers.ConnectPostgres
as follows
db, err := pghelpers.ConnectPostgres(postgresConfig)
GenerateAddress
GenerateAddress
returns a Postgres connection string, which can be used for sql.open()
.
addr := postgresConfig.GenerateAddress()
License
This project is licensed under the MIT License.
# Packages
No description provided by the author
# Functions
ConnectPostgres connects to postgres.
ExecInTx executes the provided function within a database transaction.
NewTxInstance creates a new instance of tx-db.
RegisterPostgresTxDb registers postgres to txdb.
ReleaseSavepoint releases a named savepoint previously set in the transaction.
RollbackToSavepoint rolls back the transaction to the named savepoint.
SetSavepoint sets a named savepoint in the current transaction.
# Structs
PostgresConfig holds the information for connecting with a postgres database.
# Type aliases
ExecInTxFunc defines a function type for the ExecInTx function argument.