Documentation ¶
Overview ¶
Package dmysql ...
Package dmysql ...
Package dmysql ...
Package dmysql ...
Index ¶
- Variables
- func And(conds []*Cond, orderBy, groupBy string) (sqlPattern string, args []interface{})
- func DecodeRowMap(target interface{}, r RowMap) error
- func DecodeRowMaps(sts []interface{}, rs []RowMap) error
- func Or(conds []*Cond, orderBy, groupBy string) (sqlPattern string, args []interface{})
- type AcquireConnMode
- type Cond
- func Eq(field string, val interface{}) *Cond
- func Gt(field string, val interface{}) *Cond
- func Gte(field string, val interface{}) *Cond
- func In(field string, val interface{}) *Cond
- func Like(field string, val interface{}) *Cond
- func Lt(field string, val interface{}) *Cond
- func Lte(field string, val interface{}) *Cond
- func NotEq(field string, val interface{}) *Cond
- func NotIn(field string, val interface{}) *Cond
- func NotLike(field string, val interface{}) *Cond
- type Manager
- type MySQL
- func (m *MySQL) AffectRows(ctx context.Context) int64
- func (m *MySQL) Begin(ctx context.Context) (err error)
- func (m *MySQL) Close() error
- func (m *MySQL) Commit(ctx context.Context) (err error)
- func (m *MySQL) Delete(ctx context.Context, table string, condPattern string, condArgs ...interface{}) (affect int64, err error)
- func (m *MySQL) Execute(ctx context.Context, sqlPattern string, args ...interface{}) (err error)
- func (m *MySQL) FetchAll(ctx context.Context) (all []Row, err error)
- func (m *MySQL) FetchAllMap(ctx context.Context) (allMap []RowMap, err error)
- func (m *MySQL) FetchOne(ctx context.Context) (firstCol string, err error)
- func (m *MySQL) FetchOneRow(ctx context.Context) (row Row, err error)
- func (m *MySQL) FetchRow(ctx context.Context) (rows Row, err error)
- func (m *MySQL) FetchRowMap(ctx context.Context) (rowMap RowMap, err error)
- func (m *MySQL) FetchRowMapInterface(ctx context.Context) (rowMapIntf map[string]interface{}, err error)
- func (m *MySQL) Info() string
- func (m *MySQL) Insert(ctx context.Context, table string, kvPairs map[string]interface{}) (lastID int64, err error)
- func (m *MySQL) LastInsertID(ctx context.Context) (id int64)
- func (m *MySQL) MultiInsert(ctx context.Context, table string, batchData []map[string]interface{}) (lastID int64, err error)
- func (m *MySQL) Ping() error
- func (m *MySQL) Query(ctx context.Context, sqlPattern string, args ...interface{}) (err error)
- func (m *MySQL) RollBack(ctx context.Context) (err error)
- func (m *MySQL) Select(ctx context.Context, table string, fields []string, condPattern string, ...) error
- func (m *MySQL) Update(ctx context.Context, table string, updator map[string]interface{}, ...) (affect int64, err error)
- func (m *MySQL) Upsert(ctx context.Context, table string, data map[string]interface{}, ...) (lastID int64, err error)
- type Option
- func WithAcquireConnMode(mode AcquireConnMode) Option
- func WithAutoCommit(auto bool) Option
- func WithColumnsWithAlias(colWithAlias bool) Option
- func WithDebug(debug bool) Option
- func WithDialTimeout(t time.Duration) Option
- func WithDisfServiceName(sn string, disfEnable bool) Option
- func WithKeepSilent(silent bool) Option
- func WithLoc(loc string) Option
- func WithLogger(log logger.Logger) Option
- func WithMaxConnSize(size int) Option
- func WithParseTime(parseTime bool) Option
- func WithPoolSize(size int) Option
- func WithReadTimeout(t time.Duration) Option
- func WithWriteTimeout(t time.Duration) Option
- type Row
- type RowMap
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrEmptyValues nil val ErrEmptyValues = errors.New("values is nil") // ErrEmptyTable nil table name ErrEmptyTable = errors.New("table name is nil") // ErrEmptyCondition cond is nil ErrEmptyCondition = errors.New("where condition is nil") // ErrMissMatchRow not found any row ErrMissMatchRow = errors.New("missed match") // ErrNilTransaction transaction is nil ErrNilTransaction = errors.New("transaction is nil") // ErrUnsupportedMode unsupported AcquireConnMode ErrUnsupportedMode = errors.New("unsupported AcquireConnMode") // ErrEmptyConnPool empty connection pool ErrEmptyConnPool = errors.New("empty connection pool") // ErrAcquiredConnTimeout acquire connection timed out ErrAcquiredConnTimeout = errors.New("acquire connection timed out") // ErrNotOpened close or nil db ErrNotOpened = errors.New("close or nil db") )
Functions ¶
func DecodeRowMap ¶
DecodeRowMap use reflect decode RowMap into struct
Types ¶
type AcquireConnMode ¶
type AcquireConnMode uint8
AcquireConnMode ...
const ( // AcquireConnModeUnblock return conn if there is conn or return nil if there is no free AcquireConnModeUnblock AcquireConnMode = iota // AcquireConnModeTimeout wait for free conn util timeout AcquireConnModeTimeout // AcquireConnModeBlock wait for free conn forever AcquireConnModeBlock )
type Manager ¶
type Manager struct { Connected int // contains filtered or unexported fields }
Manager Mysql conn manager
type MySQL ¶
type MySQL struct {
// contains filtered or unexported fields
}
MySQL conn obj
func (*MySQL) Delete ¶
func (m *MySQL) Delete(ctx context.Context, table string, condPattern string, condArgs ...interface{}) (affect int64, err error)
Delete ...
func (*MySQL) FetchAllMap ¶
FetchAllMap ...
func (*MySQL) FetchOneRow ¶
FetchOneRow ...
func (*MySQL) FetchRowMap ¶
FetchRowMap ...
func (*MySQL) FetchRowMapInterface ¶
func (m *MySQL) FetchRowMapInterface(ctx context.Context) (rowMapIntf map[string]interface{}, err error)
FetchRowMapInterface ...
func (*MySQL) Insert ¶
func (m *MySQL) Insert(ctx context.Context, table string, kvPairs map[string]interface{}) (lastID int64, err error)
Insert do
func (*MySQL) LastInsertID ¶
LastInsertID ...
func (*MySQL) MultiInsert ¶
func (m *MySQL) MultiInsert(ctx context.Context, table string, batchData []map[string]interface{}) (lastID int64, err error)
MultiInsert ...
func (*MySQL) Select ¶
func (m *MySQL) Select(ctx context.Context, table string, fields []string, condPattern string, condArgs ...interface{}) error
Select ...
type Option ¶
type Option func(o *option)
Option option func
func WithAcquireConnMode ¶
func WithAcquireConnMode(mode AcquireConnMode) Option
WithAcquireConnMode ...
func WithColumnsWithAlias ¶
WithColumnsWithAlias set columns
func WithDialTimeout ¶
WithDialTimeout set conn timeout
func WithDisfServiceName ¶
WithDisfServiceName set disf service name and enable disf
func WithKeepSilent ¶
WithKeepSilent ignore unusable host when init conn_pool
func WithReadTimeout ¶
WithReadTimeout set read timeout
func WithWriteTimeout ¶
WithWriteTimeout set write timeout
Click to show internal directories.
Click to hide internal directories.