sdksql

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: Unlicense Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCommand   = sdk.Errorf("brock/sdksql: invalid command")
	ErrMultipleCommands = sdk.Errorf("brock/sdksql: multiple commands")
)
View Source
var (
	ErrInvalidArguments   = sdk.Errorf("brock/sdksql: invalid arguments for scan")
	ErrInvalidTransaction = sdk.Errorf("brock/sdksql: invalid transaction")
	ErrNoColumns          = sdk.Errorf("brock/sdksql: no columns returned")
)
View Source
var Tool tool
View Source
var Wrap wrap

Functions

func ArrayPostgreSQL

func ArrayPostgreSQL(array any) interface {
	driver.Valuer
	sql.Scanner
}

func Discard

func Discard() any

func Open

func Open(dsn string) (*sql.DB, error)

Types

type BeginTx

type BeginTx interface {
	BeginTx(ctx context.Context, opts *sql.TxOptions) (tx *sql.Tx, err error)
}

type Conn

type Conn interface {
	BeginTx
	io.Closer
	PingContext
	TxConn
}

Conn is a common interface of *sql.DB and *sql.Conn.

func RoundRobin

func RoundRobin(conns ...Conn) Conn

type ExecContext

type ExecContext interface {
	ExecContext(ctx context.Context, query string, args ...any) (res sql.Result, err error)
}

type MismatchColumnsError

type MismatchColumnsError struct{ Col, Dst int }

func (*MismatchColumnsError) Error

func (err *MismatchColumnsError) Error() string

type PingContext

type PingContext interface {
	PingContext(ctx context.Context) (err error)
}

type PrepareContext

type PrepareContext interface {
	PrepareContext(ctx context.Context, query string) (stmt *sql.Stmt, err error)
}

type QueryContext

type QueryContext interface {
	QueryContext(ctx context.Context, query string, args ...any) (rows *sql.Rows, err error)
}

type QueryRowContext

type QueryRowContext interface {
	QueryRowContext(ctx context.Context, query string, args ...any) (row *sql.Row)
}

type RoundRobinError

type RoundRobinError struct{ Total, Index int }

RoundRobinError reporting issue when getting from set of Conn from RoundRobin.

func (*RoundRobinError) Error

func (err *RoundRobinError) Error() string

type TxConn

TxConn is a common interface of *sql.DB, *sql.Conn, and *sql.Tx.

type WrapExec

type WrapExec interface {
	// Scan the result of ExecContext that usually return numbers of rowsAffected
	// and lastInsertID.
	Scan(rowsAffected *int, lastInsertID *int) error
}

type WrapQuery

type WrapQuery interface {
	// Scan accept do, a func that accept `i int` as index and returning list
	// of pointers.
	//  pointers == nil   // break the loop
	//  len(pointers) < 1 // skip the current loop
	//  len(pointers) > 0 // assign the pointer, MUST be same as the length of columns
	Scan(row func(i int) (pointers []any)) error
}

type WrapQueryRow

type WrapQueryRow interface {
	Scan(dest ...any) error
	Err() error
}

type WrapTransaction

type WrapTransaction interface {
	// Do the transaction and ends it with either COMMIT or ROLLBACK
	Do(tx func() error) error
}

Jump to

Keyboard shortcuts

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