sqlw

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFrom

func CopyFrom(ctx context.Context, db *sql.DB, copyIn string, rowAdder func(cb AddRow)) error

Types

type AddRow

type AddRow func([]interface{})

type Interceptor

type Interceptor func(context.Context, string, []interface{}) error

type Interface

type Interface interface {
	sqlx.Queryer
	sqlx.QueryerContext
	sqlx.Execer
	sqlx.ExecerContext
	DBX() *sqlx.DB
}

Interface is a common wrapper over sqlx so we can compose functionality.

func WithInterceptor

func WithInterceptor(db Interface, interceptor Interceptor) Interface

WithInterceptor will call interceptor before each DB call. If interceptor returns an error, it will be returned. If the DB method does not return an error (like QueryRow), but Interceptor does, panic with the error. Usually this is used for mocking.

func WithLogging

func WithLogging(db Interface, defaultLogger *logrus.Entry) Interface

WithLogging adds logging around all calls.

func Wrap

func Wrap(db *sqlx.DB) Interface

Wrap wraps a real sqlx.DB connection into one that can be composed.

Jump to

Keyboard shortcuts

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