dbs

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SharedQueryStatManager = NewQueryStatManager()

Functions

This section is empty.

Types

type DB

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

func NewDB

func NewDB(rawDB *sql.DB) *DB

func (*DB) Begin

func (this *DB) Begin() (*sql.Tx, error)

func (*DB) Close

func (this *DB) Close() error

func (*DB) EnableStat

func (this *DB) EnableStat(b bool)

func (*DB) Exec

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

func (*DB) ExecContext

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

func (*DB) Prepare

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

func (*DB) Query

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

func (*DB) QueryRow

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

type QueryLabel

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

func NewQueryLabel

func NewQueryLabel(manager *QueryStatManager, query string) *QueryLabel

func (*QueryLabel) End

func (this *QueryLabel) End()

type QueryStat

type QueryStat struct {
	Query   string
	CostMin float64
	CostMax float64

	CostTotal float64
	Calls     int64
}

func NewQueryStat

func NewQueryStat(query string) *QueryStat

func (*QueryStat) AddCost

func (this *QueryStat) AddCost(cost float64)

type QueryStatManager

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

func NewQueryStatManager

func NewQueryStatManager() *QueryStatManager

func (*QueryStatManager) AddCost

func (this *QueryStatManager) AddCost(query string, cost float64)

func (*QueryStatManager) AddQuery

func (this *QueryStatManager) AddQuery(query string) *QueryLabel

func (*QueryStatManager) TopN

func (this *QueryStatManager) TopN(n int) []*QueryStat

type Stmt

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

func NewStmt

func NewStmt(rawStmt *sql.Stmt, query string) *Stmt

func (*Stmt) Close

func (this *Stmt) Close() error

func (*Stmt) EnableStat

func (this *Stmt) EnableStat()

func (*Stmt) Exec

func (this *Stmt) Exec(args ...interface{}) (sql.Result, error)

func (*Stmt) ExecContext

func (this *Stmt) ExecContext(ctx context.Context, args ...interface{}) (sql.Result, error)

func (*Stmt) Query

func (this *Stmt) Query(args ...interface{}) (*sql.Rows, error)

func (*Stmt) QueryContext

func (this *Stmt) QueryContext(ctx context.Context, args ...interface{}) (*sql.Rows, error)

func (*Stmt) QueryRow

func (this *Stmt) QueryRow(args ...interface{}) *sql.Row

func (*Stmt) QueryRowContext

func (this *Stmt) QueryRowContext(ctx context.Context, args ...interface{}) *sql.Row

Jump to

Keyboard shortcuts

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