sql

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2021 License: Apache-2.0 Imports: 3 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v0.1.0

type Config interface {
	// DriverName ... FIXME
	DriverName() string

	// DSN ... FIXME
	DSN() string
}

Config ... FIXME

type DB

type DB interface {
	Begin(ctx context.Context, opts *TxOptions) (Tx, error)

	Exec(ctx context.Context, query string, args ...interface{}) (Result, error)
	Prepare(ctx context.Context, query string) (Stmt, error)
	Query(ctx context.Context, query string, args ...interface{}) (*Rows, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) *Row

	Close() error
	Ping(ctx context.Context) error
}

func Open

func Open(config Config, opts ...Option) (DB, error)

type Logger added in v0.1.0

type Logger = log.Logger

What I would like:

type Logger[L any] interface {
	WithField(key string, value interface{}) L

	Infoln(args ...interface{})
	Infof(format string, args ...interface{})
}

type Option

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

Option sets options such as instumenting the DB with logging.

func WithLogger added in v0.1.0

func WithLogger(logger Logger) Option

WithLogger returns an Option that instruments the DB with logging.

type Result

type Result = sql.Result

type Row

type Row = sql.Row

type Rows

type Rows = sql.Rows

type Stmt added in v0.1.0

type Stmt interface {
	Exec(ctx context.Context, args ...interface{}) (Result, error)
	Query(ctx context.Context, args ...interface{}) (*Rows, error)
	QueryRow(ctx context.Context, args ...interface{}) *Row

	Close() error
}

type Tx

type Tx interface {
	Exec(ctx context.Context, query string, args ...interface{}) (Result, error)
	Prepare(ctx context.Context, query string) (Stmt, error)
	Query(ctx context.Context, query string, args ...interface{}) (*Rows, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) *Row

	Commit() error
	Rollback() error

	Stmt(ctx context.Context, stmt Stmt) Stmt
}

type TxOptions

type TxOptions = sql.TxOptions

Directories

Path Synopsis
Package mocksql is a generated GoMock package.
Package mocksql is a generated GoMock package.

Jump to

Keyboard shortcuts

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