sq

package
v0.0.43 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScanAll added in v0.0.34

func ScanAll[TData any](rows *sqlx.Rows, close bool) ([]TData, error)

func ScanSingle added in v0.0.34

func ScanSingle[TData any](rows *sqlx.Rows, close bool) (TData, error)

Types

type DB

type DB interface {
	Exec(ctx context.Context, sql string, prep PP) (sql.Result, error)
	Query(ctx context.Context, sql string, prep PP) (*sqlx.Rows, error)
	Ping(ctx context.Context) error
	BeginTransaction(ctx context.Context, iso sql.IsolationLevel) (Tx, error)
	AddListener(listener Listener)
	Exit() error
}

func NewDB

func NewDB(db *sqlx.DB) DB

type Listener

type Listener interface {
	PrePing(ctx context.Context) error
	PreTxBegin(ctx context.Context, txid uint16) error
	PreTxCommit(txid uint16) error
	PreTxRollback(txid uint16) error
	PreQuery(ctx context.Context, txID *uint16, sql *string, params *PP) error
	PreExec(ctx context.Context, txID *uint16, sql *string, params *PP) error

	PostPing(result error)
	PostTxBegin(txid uint16, result error)
	PostTxCommit(txid uint16, result error)
	PostTxRollback(txid uint16, result error)
	PostQuery(txID *uint16, sqlOriginal string, sqlReal string, params PP)
	PostExec(txID *uint16, sqlOriginal string, sqlReal string, params PP)
}

type PP

type PP map[string]any

type Queryable

type Queryable interface {
	Exec(ctx context.Context, sql string, prep PP) (sql.Result, error)
	Query(ctx context.Context, sql string, prep PP) (*sqlx.Rows, error)
}

type Tx

type Tx interface {
	Rollback() error
	Commit() error
	Exec(ctx context.Context, sql string, prep PP) (sql.Result, error)
	Query(ctx context.Context, sql string, prep PP) (*sqlx.Rows, error)
}

func NewTransaction

func NewTransaction(xtx *sqlx.Tx, txid uint16, lstr []Listener) Tx

Jump to

Keyboard shortcuts

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