Documentation ¶
Index ¶
- Constants
- func Exec(query string, args ...interface{}) (LastInsertId, RowsAffected int64, err error)
- func Get(dest interface{}, query string, args ...interface{}) error
- func Limit(page, pagesize int) string
- func NamedExec(query string, args interface{}) (LastInsertId, RowsAffected int64, err error)
- func NamedGet(dest interface{}, query string, args interface{}) (err error)
- func NamedSelect(dest interface{}, query string, args interface{}) (err error)
- func Ping() error
- func PingContext(ctx context.Context) error
- func Release(dbx *DB) (err error)
- func ReleaseDefault() error
- func Select(dest interface{}, query string, args ...interface{}) error
- func SetDefaultOption(opt Option) (err error)
- func Stats() sql.DBStats
- type DB
- func (d *DB) BeginTrans() (err error)
- func (d *DB) Commit() error
- func (d *DB) Connect() (err error)
- func (d *DB) Exec(query string, args ...interface{}) (LastInsertId, RowsAffected int64, err error)
- func (d *DB) Get(dest interface{}, query string, args ...interface{}) (err error)
- func (d *DB) Limit(page, pagesize int) string
- func (d *DB) NamedExec(query string, args interface{}) (LastInsertId, RowsAffected int64, err error)
- func (d *DB) NamedGet(dest interface{}, query string, args interface{}) (err error)
- func (d *DB) NamedSelect(dest interface{}, query string, args interface{}) (err error)
- func (d *DB) Ping() error
- func (d *DB) PingContext(ctx context.Context) error
- func (d *DB) Rollback() error
- func (d *DB) Select(dest interface{}, query string, args ...interface{}) error
- func (d *DB) Stats() sql.DBStats
- func (d *DB) Trans() (tx *Tx, err error)
- func (d *DB) TransExec(query string, args ...interface{}) (LastInsertId, RowsAffected int64, err error)
- func (d *DB) TransGet(dest interface{}, query string, args ...interface{}) (err error)
- func (d *DB) TransNamedExec(query string, args interface{}) (LastInsertId, RowsAffected int64, err error)
- func (d *DB) TransNamedGet(dest interface{}, query string, args interface{}) (err error)
- func (d *DB) TransSelect(dest interface{}, query string, args ...interface{}) (err error)
- type Option
- type Tx
- func (t *Tx) Commit() error
- func (t *Tx) Rollback() error
- func (t *Tx) TransExec(query string, args ...interface{}) (LastInsertId, RowsAffected int64, err error)
- func (t *Tx) TransGet(dest interface{}, query string, args ...interface{}) (err error)
- func (t *Tx) TransNamedExec(query string, args interface{}) (LastInsertId, RowsAffected int64, err error)
- func (t *Tx) TransNamedGet(dest interface{}, query string, args interface{}) (err error)
- func (t *Tx) TransSelect(dest interface{}, query string, args ...interface{}) (err error)
Constants ¶
const ( // DriverPostgres postgres DriverPostgres = `postgres` // DriverMySQL MySQL DriverMySQL = `mysql` )
Variables ¶
This section is empty.
Functions ¶
func NamedSelect ¶
NamedSelect select rows, named bindvars
func Ping ¶
func Ping() error
Ping verifies a connection to the database is still alive, establishing a connection if necessary.
func PingContext ¶
PingContext verifies a connection to the database is still alive, establishing a connection if necessary.
func SetDefaultOption ¶
SetDefaultOption default connect option
Types ¶
type DB ¶
type DB struct { Driver string // contains filtered or unexported fields }
DB db
func (*DB) NamedExec ¶
func (d *DB) NamedExec(query string, args interface{}) (LastInsertId, RowsAffected int64, err error)
NamedExec exec, named bindvars
func (*DB) NamedSelect ¶
NamedSelect select rows, named bindvars
func (*DB) Ping ¶
Ping verifies a connection to the database is still alive, establishing a connection if necessary.
func (*DB) PingContext ¶
PingContext verifies a connection to the database is still alive, establishing a connection if necessary.
func (*DB) TransExec ¶
func (d *DB) TransExec(query string, args ...interface{}) (LastInsertId, RowsAffected int64, err error)
TransNamedExec trans execute
func (*DB) TransNamedExec ¶
func (d *DB) TransNamedExec(query string, args interface{}) (LastInsertId, RowsAffected int64, err error)
TransNamedExec trans execute, named bindvars
func (*DB) TransNamedGet ¶
TransNamedGet trans get row, named bindvars
func (*DB) TransSelect ¶
TransSelect trans get rows
type Option ¶
type Option struct { Driver string DNS string MaxOpenConns int MaxIdle int MaxLifetime time.Duration }
Option option
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
func (*Tx) TransExec ¶
func (t *Tx) TransExec(query string, args ...interface{}) (LastInsertId, RowsAffected int64, err error)
TransNamedExec trans execute
func (*Tx) TransNamedExec ¶
func (t *Tx) TransNamedExec(query string, args interface{}) (LastInsertId, RowsAffected int64, err error)
TransNamedExec trans execute, named bindvars
func (*Tx) TransNamedGet ¶
TransNamedGet trans get row, named bindvars
func (*Tx) TransSelect ¶
TransSelect trans get rows