postgrespgxdb

package
v0.0.123 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package postgrespgxdb provides constructor to connect to postgresql with pgx

Index

Constants

View Source
const (
	// SCMPrepare
	// Statement Cache Mode value - "prepare" - is default
	SCMPrepare = "prepare"

	// SCMDescribe
	// Statement Cache Mode value - "describe" - use it for PGBouncer connections
	SCMDescribe = "describe"
)
View Source
const (
	ConstraintErrorCode = "23505"
)

Variables

This section is empty.

Functions

func IsConstraintError added in v0.0.90

func IsConstraintError(err error, name string) bool

Types

type AffectedLessThenNecessaryError added in v0.0.90

type AffectedLessThenNecessaryError struct {
	Affected  int64
	Necessary int64
}

func (*AffectedLessThenNecessaryError) Error added in v0.0.90

type Config

type Config struct {
	Host               string
	Port               string
	Name               string
	User               string
	Password           string
	SSLMode            string
	BinaryParameters   string // lib/pq setting for prepared statements in pgbouncer
	StatementCacheMode string
	MaxConnections     string
}

Config describe connection params to database

func (*Config) GetDSN

func (cfg *Config) GetDSN() string

GetDSN return DSN string for db connection params

type Conn

type Conn struct {
	*pgxpool.Pool
	*types.DBLog
}

Conn database connection and log

type DBQuery

type DBQuery interface {
	Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
	Query(ctx context.Context, sql string, optionsAndArgs ...interface{}) (pgx.Rows, error)
	QueryRow(ctx context.Context, sql string, optionsAndArgs ...interface{}) pgx.Row
	Begin(ctx context.Context) (pgx.Tx, error)
	BeginTx(ctx context.Context, txOptions pgx.TxOptions) (pgx.Tx, error)
	SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults
	Close()
	types.SQLLogger
}

DBQuery describe interface

func New

func New(cfg *Config, log types.SQLLoggerFunc) (DBQuery, error)

New create new database connection

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL