Documentation ¶
Index ¶
- Constants
- Variables
- type DBConf
- type DBConn
- func (dbConn *DBConn) Begin(context context.Context) (txConn *DBConn, err error)
- func (dbConn *DBConn) Commit(context context.Context) (err error)
- func (dbConn *DBConn) Exec(context context.Context, sql string, values ...interface{}) (result int64, err error)
- func (dbConn *DBConn) JDBC() (dsn string)
- func (dbConn *DBConn) Query(context context.Context, result interface{}, sql string, values ...interface{}) (err error)
- func (dbConn *DBConn) Rollback(context context.Context) (err error)
- type DBConnConf
- type DBGroup
- func (dbGroup *DBGroup) Begin(context context.Context) (tx *DBConn, err error)
- func (dbGroup *DBGroup) Exec(context context.Context, sql string, values ...interface{}) (result int64, err error)
- func (DBGroup *DBGroup) ORM() *DBOrm
- func (dbGroup *DBGroup) Query(context context.Context, result interface{}, sql string, values ...interface{}) (err error)
- func (dbGroup *DBGroup) QueryWithOptions(context context.Context, dbOptions *DBOptions, result interface{}, sql string, ...) (err error)
- type DBGroupConf
- type DBManager
- type DBOptions
- type DBOrm
- func (dbOrm *DBOrm) Delete(context context.Context, table string, whereConds map[string]interface{}, ...) (result int64, err error)
- func (dbOrm *DBOrm) Escape(sql string) string
- func (dbOrm *DBOrm) Insert(context context.Context, table string, insertMap map[string]interface{}, ...) (result int64, err error)
- func (dbOrm *DBOrm) Select(context context.Context, result interface{}, table string, ...) (err error)
- func (dbOrm *DBOrm) Update(context context.Context, table string, updateMap map[string]interface{}, ...) (result int64, err error)
- type DBOtherConds
- type DBSubGroupConf
Constants ¶
Variables ¶
View Source
var ( ERR_DB_GROUP_NOT_FOUND = errors.New("此DB不存在") ERR_DB_CONN_NOT_FOUND = errors.New("没有可用DB连接") ERR_QUERY_RESULT_INVALID = errors.New("result传参类型必须是*[]*ElemType") ERR_RECURSION_TX = errors.New("嵌套开启了事务") ERR_INVALID_TX = errors.New("非事务不能提交或回滚") ERR_INVALID_PARAM = errors.New("错误的参数") ERR_BEGIN_TX_FAILED = errors.New("开启事务失败") )
错误码
View Source
var DEFAULT_DBOPTION = &DBOptions{}
View Source
var DEFAULT_OTHER_CONDS = &DBOtherConds{
Fields: "*",
GroupBy: "",
OrderBy: "",
Limit: "",
}
Functions ¶
This section is empty.
Types ¶
type DBConf ¶
type DBConf struct {
GroupConfList []DBGroupConf `toml:"Group"`
}
type DBConn ¶
type DBConn struct {
// contains filtered or unexported fields
}
单个Mysql连接
func (*DBConn) Exec ¶
func (dbConn *DBConn) Exec(context context.Context, sql string, values ...interface{}) (result int64, err error)
SQL写入
type DBConnConf ¶
单实例配置
type DBGroup ¶
func (*DBGroup) Exec ¶
func (dbGroup *DBGroup) Exec(context context.Context, sql string, values ...interface{}) (result int64, err error)
SQL写入
type DBGroupConf ¶
type DBGroupConf struct { Name string `toml:"name"` Database string `toml:"database"` // 数据库名称 Username string `toml:"username"` // 用户名 Password string `toml:"password"` // 密码 Master *DBSubGroupConf `toml:"Master"` // 主库配置 Slaves *DBSubGroupConf `toml:"Slave"` // 从库配置 }
Mysql主从配置
type DBOrm ¶
type DBOrm struct {
Parent *DBGroup
}
func (*DBOrm) Delete ¶
func (dbOrm *DBOrm) Delete(context context.Context, table string, whereConds map[string]interface{}, dbOptions *DBOptions) (result int64, err error)
删除
func (*DBOrm) Insert ¶
func (dbOrm *DBOrm) Insert(context context.Context, table string, insertMap map[string]interface{}, dbOptions *DBOptions) (result int64, err error)
插入
type DBOtherConds ¶
type DBSubGroupConf ¶
type DBSubGroupConf struct { MaxConn int `toml:"maxConn"` // 最大连接数 IdleConn int `toml:"idleConn"` // 最大保持连接数 IdleTime int `toml:"idleTime"` // 空闲回收时间 ReadTimeout int `toml:"readTimeout"` // 读超时时间 WriteTimeout int `toml:"writeTimeout"` // 写超时时间 Timeout int `toml:"Timeout"` // 超时时间 Instances []DBConnConf `toml:"Instance"` // 实例列表 }
Master 或者 Slave配置
Click to show internal directories.
Click to hide internal directories.