postgres

package
v0.0.0-...-495eea3 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComposeUpsert

func ComposeUpsert(fields []Field) (string, string, string, []interface{})

Builds the values needed to compose an upsert statement

func New

func New(c *Config) (*sqlx.DB, error)

New returns a new database client

func WrapError

func WrapError(err error) error

Types

type Config

type Config struct {
	Username            string        `conf:"username" default:"postgres"`
	Password            string        `conf:"password" default:"password"`
	Host                string        `conf:"host" default:"postgres"`
	Port                string        `conf:"port" default:"5432"`
	Database            string        `conf:"database" default:"postgres"`
	AutoCreate          bool          `conf:"auto_create" default:"false"`
	SearchPath          string        `conf:"search_path" default:""`
	SSLMode             string        `conf:"sslmode" default:"false"`
	SSLCert             string        `conf:"sslcert" default:""`
	SSLKey              string        `conf:"sslkey" default:""`
	SSLRootCert         string        `conf:"sslrootcert" default:""`
	Retries             int           `conf:"retries" default:"5"`
	SleepBetweenRetries time.Duration `conf:"sleep_between_retries" default:"7s"`
	MaxConnections      int           `conf:"max_connections" default:"40"`
	WipeConfirm         bool          `conf:"wipe_confirm" default:"false"`

	Logger          Logger
	QueryLogger     Logger
	MigrationSource source.Driver
}

type Field

type Field struct {
	Name   string
	Insert string
	Update string
	Arg    interface{}
}

type Logger

type Logger interface {
	Printf(template string, args ...interface{})
}

The Logger Inferface for the database driver.

Jump to

Keyboard shortcuts

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