sql

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Closer

type Closer interface {
	Close() error
}

type DB

type DB interface {
	Begin(ctx context.Context, opts *TxOptions) (Tx, error)
	Closer
	Executor
	Ping(ctx context.Context) error
	Preparer
	Querier

	GetDB() *sql.DB
}

func New

func New(db *sql.DB) DB

func Open

func Open(driverName, dsn string) (DB, error)

func WithLogger

func WithLogger(db DB, logger log.Logger) DB

type Executor

type Executor interface {
	Exec(ctx context.Context, query string, args ...interface{}) (Result, error)
}

type Preparer

type Preparer interface {
	Prepare(ctx context.Context, query string) (Stmt, error)
}

type Querier

type Querier interface {
	Query(ctx context.Context, query string, args ...interface{}) (*Rows, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) *Row
}

type Result

type Result = sql.Result

type Row

type Row = sql.Row

type Rows

type Rows = sql.Rows

type Stmt

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

	GetStmt() *sql.Stmt
}

type Tx

type Tx interface {
	Commit() error
	Executor
	Preparer
	Querier
	Rollback() error
	Stmt(ctx context.Context, stmt Stmt) Stmt

	GetTx() *sql.Tx
}

type TxOptions

type TxOptions = sql.TxOptions

Jump to

Keyboard shortcuts

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