sqlquerywrapper

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*sql.DB
	// contains filtered or unexported fields
}

func New

func New(db *sql.DB, opts ...Opt) *DB

func (*DB) Begin

func (db *DB) Begin() (*Tx, error)

Begin starts a transaction.

Use BeginTx to pass context and options to the underlying driver.

func (*DB) BeginTx

func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)

func (*DB) Exec

func (db *DB) Exec(query string, args ...interface{}) (sql.Result, error)

func (*DB) ExecContext

func (db *DB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*DB) Query

func (db *DB) Query(query string, args ...interface{}) (*Rows, error)

func (*DB) QueryContext

func (db *DB) QueryContext(ctx context.Context, query string, args ...interface{}) (*Rows, error)

func (*DB) QueryRow

func (db *DB) QueryRow(query string, args ...interface{}) *Row

func (*DB) QueryRowContext

func (db *DB) QueryRowContext(ctx context.Context, query string, args ...interface{}) *Row

func (*DB) WithTx

func (db *DB) WithTx(ctx context.Context, fn func(*Tx) error) error

type Opt

type Opt func(*DB)

func WithKeyAndValues

func WithKeyAndValues(keyAndValues ...any) Opt

func WithLogger

func WithLogger(logger logger) Opt

func WithQueryTimeout added in v1.10.0

func WithQueryTimeout(timeout time.Duration) Opt

WithQueryTimeout imposes a timeout on each query

func WithSecretsRegex

func WithSecretsRegex(secretsRegex map[string]string) Opt

func WithSlowQueryThreshold

func WithSlowQueryThreshold(slowQueryThreshold time.Duration) Opt

func WithTransactionTimeout added in v1.10.0

func WithTransactionTimeout(timeout time.Duration) Opt

WithTransactionTimeout imposes a timeout on the transaction

type Row added in v1.10.0

type Row struct {
	*sql.Row
	context.CancelFunc
	// contains filtered or unexported fields
}

func (*Row) Err added in v1.10.0

func (r *Row) Err() error

func (*Row) Scan added in v1.10.0

func (r *Row) Scan(dest ...interface{}) error

type Rows added in v1.10.0

type Rows struct {
	*sql.Rows
	context.CancelFunc
	// contains filtered or unexported fields
}

func (*Rows) Close added in v1.10.0

func (r *Rows) Close() error

func (*Rows) Err added in v1.10.0

func (r *Rows) Err() error

func (*Rows) Next added in v1.10.0

func (r *Rows) Next() bool

func (*Rows) Scan added in v1.10.0

func (r *Rows) Scan(dest ...interface{}) error

type Tx

type Tx struct {
	*sql.Tx

	context.CancelFunc
	// contains filtered or unexported fields
}

func (*Tx) Commit

func (tx *Tx) Commit() error

func (*Tx) Exec

func (tx *Tx) Exec(query string, args ...interface{}) (sql.Result, error)

func (*Tx) ExecContext

func (tx *Tx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func (*Tx) GetTx added in v1.10.0

func (tx *Tx) GetTx() *sql.Tx

func (*Tx) Query

func (tx *Tx) Query(query string, args ...interface{}) (*Rows, error)

func (*Tx) QueryContext

func (tx *Tx) QueryContext(ctx context.Context, query string, args ...interface{}) (*Rows, error)

func (*Tx) QueryRow

func (tx *Tx) QueryRow(query string, args ...interface{}) *Row

func (*Tx) QueryRowContext

func (tx *Tx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *Row

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Jump to

Keyboard shortcuts

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