db

package
v3.19.2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2020 License: MIT Imports: 9 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoHost occurs when host is not provided in configuration
	ErrNoHost = errors.New("no host for database connection")

	// SQLTimeout when running queries
	SQLTimeout = time.Second * 5
)

Functions

func Create added in v3.16.0

func Create(ctx context.Context, query string, args ...interface{}) (uint64, error)

Create execute query with a RETURNING id

func DoAtomic added in v3.19.0

func DoAtomic(ctx context.Context, db *sql.DB, action func(context.Context) error) error

DoAtomic execute given action in a transactionnal context

func Exec added in v3.16.0

func Exec(ctx context.Context, query string, args ...interface{}) error

Exec execute query with specified timeout, disregarding result

func GetRow added in v3.16.0

func GetRow(ctx context.Context, db *sql.DB, scanner func(RowScanner) error, query string, args ...interface{}) error

GetRow execute single row query

func New

func New(config Config) (*sql.DB, error)

New creates new App from Config

func Ping

func Ping(db *sql.DB) bool

Ping indicate if database is ready or not

func RowsClose

func RowsClose(rows *sql.Rows, err error) error

RowsClose closes rows without shadowing error

func StoreTx added in v3.16.1

func StoreTx(ctx context.Context, tx *sql.Tx) context.Context

StoreTx stores given transaction in context

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config of package

func Flags

func Flags(fs *flag.FlagSet, prefix string) Config

Flags adds flags for configuring package

type RowScanner added in v3.16.0

type RowScanner interface {
	Scan(...interface{}) error
}

RowScanner describes scan ability of a row

Jump to

Keyboard shortcuts

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