pgsx

package
v0.0.0-...-95edb15 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilDBClient         = errors.New("db client is nil")
	ErrNilPostgresClient   = errors.New("postgres client is nil")
	ErrDuplicateKey        = errors.New("duplicate key")
	ErrCheckViolation      = errors.New("check constraint violation")
	ErrForeignKeyViolation = errors.New("foreign key violation")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	DB *sqlx.DB
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg Config, fs *embed.FS) (*Client, error)

NewClient initializes database connection

func (*Client) Close

func (c *Client) Close() error

func (*Client) Execs

func (c *Client) Execs(ctx context.Context, queries []string) error

Execs is used for executing list of db query

func (*Client) Migrate

func (c *Client) Migrate(cfg Config) (err error)

func (*Client) RunWithinTx

func (c *Client) RunWithinTx(ctx context.Context, f func(tx *sqlx.Tx) error) error

type Config

type Config struct {
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Name     string `yaml:"name"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	SSLMode  string `yaml:"sslmode"`
}

func (*Config) ConnURL

func (c *Config) ConnURL() *url.URL

ConnURL returns the connection URL for the Postgres database.

Jump to

Keyboard shortcuts

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