sql

package
v0.48.5 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Adding in aliases for the usual error cases
	ErrNoRows   = sql.ErrNoRows
	ErrConnDone = sql.ErrConnDone
	ErrTxDone   = sql.ErrTxDone
)

Functions

func CleanQuery

func CleanQuery(s string) string

func MeasureError

func MeasureError(id string, err error) error

func MeasureQuery

func MeasureQuery(logger LazyLogger, slowQueryThresholdMs int64, id string, op string, qry string, args int) func() int64

func MeasureStats

func MeasureStats(db *sql.DB, id string) error

func MonitorSQLDriver

func MonitorSQLDriver(db *sql.DB, id string) context.CancelFunc

Types

type DB

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

func ObserveDB

func ObserveDB(innerDB *gosql.DB, logger log.Logger, id string) (*DB, error)

func (*DB) Begin

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

func (*DB) BeginTx

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

func (*DB) Close

func (w *DB) Close() error

func (*DB) Exec

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

func (*DB) ExecContext

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

func (*DB) Prepare

func (w *DB) Prepare(query string) (*Stmt, error)

func (*DB) PrepareContext

func (w *DB) PrepareContext(ctx context.Context, query string) (*Stmt, error)

func (*DB) Query

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

func (*DB) QueryContext

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

func (*DB) QueryRow

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

func (*DB) QueryRowContext

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

func (*DB) SetSlowQueryThreshold

func (w *DB) SetSlowQueryThreshold(d time.Duration)

type LazyLogger

type LazyLogger func() log.Logger

type Stmt

type Stmt struct {
	// contains filtered or unexported fields
}

func (*Stmt) Close

func (s *Stmt) Close() error

func (*Stmt) Exec

func (s *Stmt) Exec(args ...any) (gosql.Result, error)

func (*Stmt) ExecContext

func (s *Stmt) ExecContext(ctx context.Context, args ...any) (gosql.Result, error)

func (*Stmt) Query

func (s *Stmt) Query(args ...any) (*gosql.Rows, error)

func (*Stmt) QueryContext

func (s *Stmt) QueryContext(ctx context.Context, args ...any) (*gosql.Rows, error)

func (*Stmt) QueryRow

func (s *Stmt) QueryRow(args ...any) *gosql.Row

func (*Stmt) QueryRowContext

func (s *Stmt) QueryRowContext(ctx context.Context, args ...any) *gosql.Row

type Tx

type Tx struct {
	*gosql.Tx
	// contains filtered or unexported fields
}

func (*Tx) Commit

func (w *Tx) Commit() error

func (*Tx) Context

func (w *Tx) Context() context.Context

func (*Tx) Exec

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

func (*Tx) ExecContext

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

func (*Tx) PrepareContext

func (w *Tx) PrepareContext(ctx context.Context, query string) (*Stmt, error)

func (*Tx) Query

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

func (*Tx) QueryContext

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

func (*Tx) QueryRow

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

func (*Tx) QueryRowContext

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

func (*Tx) Rollback

func (w *Tx) Rollback() error

type TxOptions

type TxOptions = gosql.TxOptions

Jump to

Keyboard shortcuts

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