Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrBreak = uerror.New(300, "break")
Functions ¶
Types ¶
type NextFunc ¶ added in v0.0.17
NextFunc is designed for scanning all rows queryed from the database If error returned, it will cancel the loop in advance, and it will return the error. If ErrBreak returned, it will also cancel the loop in advance, but it will nil. If nil returned, it represents everything is OK.
type Option ¶
type Option struct { Address string `json:"address"` DBName string `json:"dbname"` Username string `json:"username"` Password string `json:"password"` Port int `json:"port"` // MaxOpenConns sets the maximum number of open connections to the database MaxOpenConns int `json:"max_open_conns"` // MaxIdleConns sets the maximum number of connections in the idle connection pool. MaxIdleConns int `json:"max_idle_conns"` }
type Proxy ¶ added in v0.0.17
type Proxy interface { // Transaction will start a transaction for the database // Ex. // p.Transaction(ctx, func(tx *sql.Tx) error { // tx.Exec(xxx) // return nil // it will commit the transaction automatically // }) Transaction(ctx context.Context, fn TxFunc) error Query(ctx context.Context, query string, next NextFunc, args ...interface{}) error // QueryRow will query a row from the database // Ex. // var v1 string // if err := p.QueryRow(ctx, `SELECT xx FROM xx`, []interface{}{&v1}, args); err != nil { // // error // } QueryRow(ctx context.Context, query string, dest []interface{}, args ...interface{}) error Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error) }
Proxy is a abstract layer for operating the MySQL database
Click to show internal directories.
Click to hide internal directories.