dbs

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SyncMode = "OFF"
)

Variables

View Source
var SharedQueryStatManager = NewQueryStatManager()

Functions

func IsClosedErr added in v1.2.1

func IsClosedErr(err error) bool

Types

type Batch added in v0.5.2

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

func NewBatch added in v0.5.2

func NewBatch(db *DB, n int) *Batch

func (*Batch) Add added in v0.5.2

func (this *Batch) Add(query string, args ...any)

func (*Batch) EnableStat added in v0.5.2

func (this *Batch) EnableStat(b bool)

func (*Batch) Exec added in v0.5.2

func (this *Batch) Exec()

func (*Batch) OnFail added in v0.5.2

func (this *Batch) OnFail(callback func(err error))

type DB

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

func NewDB

func NewDB(rawDB *sql.DB, dsn string) *DB

func OpenReader added in v0.6.4

func OpenReader(dsn string) (*DB, error)

func OpenWriter added in v0.6.4

func OpenWriter(dsn string) (*DB, error)

func (*DB) Begin

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

func (*DB) BeginUpdating added in v1.2.1

func (this *DB) BeginUpdating() bool

func (*DB) Close

func (this *DB) Close() error

Close the database

func (*DB) EnableStat

func (this *DB) EnableStat(b bool)

func (*DB) EndUpdating added in v1.2.1

func (this *DB) EndUpdating()

func (*DB) Exec

func (this *DB) Exec(query string, args ...any) (sql.Result, error)

func (*DB) ExecContext

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

func (*DB) Prepare

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

func (*DB) Query

func (this *DB) Query(query string, args ...any) (*sql.Rows, error)

func (*DB) QueryRow

func (this *DB) QueryRow(query string, args ...any) *sql.Row

func (*DB) RawDB added in v0.5.2

func (this *DB) RawDB() *sql.DB

func (*DB) SetMaxOpenConns added in v0.6.4

func (this *DB) SetMaxOpenConns(n int)

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(db *DB, 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 ...any) (result sql.Result, err error)

func (*Stmt) ExecContext

func (this *Stmt) ExecContext(ctx context.Context, args ...any) (result sql.Result, err error)

func (*Stmt) Query

func (this *Stmt) Query(args ...any) (*sql.Rows, error)

func (*Stmt) QueryContext

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

func (*Stmt) QueryRow

func (this *Stmt) QueryRow(args ...any) *sql.Row

func (*Stmt) QueryRowContext

func (this *Stmt) QueryRowContext(ctx context.Context, args ...any) *sql.Row

Jump to

Keyboard shortcuts

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