sqlz

package
v0.0.59-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2023 License: Apache-2.0 Imports: 7 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMustBePointer        = errors.New("sql: must be pointer")
	ErrMustNotNil           = errors.New("sql: must not nil")
	ErrDataTypeNotSupported = errors.New("sql: data type not supported")
)

Functions

func MustBeginTx

func MustBeginTx(ctx context.Context, db sqlTxBeginner, opts *sql.TxOptions) *sql.Tx

func MustOpenContext added in v0.0.57

func MustOpenContext(ctx context.Context, driverName string, dataSourceName string) *sql.DB

func OpenContext added in v0.0.57

func OpenContext(ctx context.Context, driverName string, dataSourceName string) (*sql.DB, error)

func ScanRows

func ScanRows(rows sqlRows, structTag string, dst interface{}) error

ScanRows scans rows to dst.

structTag is used to get column names from struct tags.

dst must be a pointer. If dst is a pointer to a struct or a slice of struct, column names are got from structTag. If dst is a pointer to a slice of primitive, ignore structTag.

Types

type NewDBOption added in v0.0.57

type NewDBOption interface {
	// contains filtered or unexported methods
}

func WithNewDBOptionStructTag added in v0.0.57

func WithNewDBOptionStructTag(structTag string) NewDBOption

type QueryerContext added in v0.0.57

type QueryerContext interface {
	// QueryContext executes a query that returns rows, typically a SELECT.
	//
	// The dst must be a pointer.
	// The args are for any placeholder parameters in the query.
	QueryContext(ctx context.Context, dst interface{}, query string, args ...interface{}) error
	// QueryRowContext executes a query that is expected to return at most one row.
	// It always returns a non-nil value or an error.
	//
	// The dst must be a pointer.
	// The args are for any placeholder parameters in the query.
	QueryRowContext(ctx context.Context, dst interface{}, query string, args ...interface{}) error
}

func NewDB

func NewDB(db sqlQueryerContext, opts ...NewDBOption) QueryerContext

Jump to

Keyboard shortcuts

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