Documentation
¶
Index ¶
- Constants
- func SetTrace(t bool)
- type Config
- type Connection
- type DbError
- type Epr
- type Grammar
- type Proxy
- type QueryBuilder
- func (query *QueryBuilder) Between(column string, value1 interface{}, value2 interface{}) *QueryBuilder
- func (query *QueryBuilder) Count() (int64, error)
- func (query *QueryBuilder) Delete() (int64, error)
- func (query *QueryBuilder) DeleteSQL() string
- func (query *QueryBuilder) Distinct() *QueryBuilder
- func (query *QueryBuilder) Equal(column string, value interface{}) *QueryBuilder
- func (query *QueryBuilder) Exec(sql string, args ...interface{}) (int64, error)
- func (query *QueryBuilder) ExecSQL(sql string, args ...interface{}) string
- func (query *QueryBuilder) GroupBy(groups ...string) *QueryBuilder
- func (query *QueryBuilder) In(column string, value ...interface{}) *QueryBuilder
- func (query *QueryBuilder) InnerJoin(tablename string, on string) *QueryBuilder
- func (query *QueryBuilder) Insert(data interface{}) (int64, error)
- func (query *QueryBuilder) InsertSQL(data interface{}) string
- func (query *QueryBuilder) InsertUpdate(insert interface{}, update interface{}) (int64, error)
- func (query *QueryBuilder) InsertUpdateSQL(insert interface{}, update interface{}) string
- func (query *QueryBuilder) IsNULL(column string) *QueryBuilder
- func (query *QueryBuilder) IsNotNULL(column string) *QueryBuilder
- func (query *QueryBuilder) Join(tablename string, on string) *QueryBuilder
- func (query *QueryBuilder) LeftJoin(tablename string, on string) *QueryBuilder
- func (query *QueryBuilder) Like(column string, value interface{}) *QueryBuilder
- func (query *QueryBuilder) Limit(limit int64) *QueryBuilder
- func (query *QueryBuilder) MultiInsert(datas ...interface{}) (int64, error)
- func (query *QueryBuilder) MultiInsertSQL(datas ...interface{}) string
- func (query *QueryBuilder) NotBetween(column string, value1 interface{}, value2 interface{}) *QueryBuilder
- func (query *QueryBuilder) NotEqual(column string, value interface{}) *QueryBuilder
- func (query *QueryBuilder) NotIn(column string, value ...interface{}) *QueryBuilder
- func (query *QueryBuilder) NotOrBetween(column string, value1 interface{}, value2 interface{}) *QueryBuilder
- func (query *QueryBuilder) Offset(offset int64) *QueryBuilder
- func (query *QueryBuilder) OrBetween(column string, value1 interface{}, value2 interface{}) *QueryBuilder
- func (query *QueryBuilder) OrEqual(column string, value interface{}) *QueryBuilder
- func (query *QueryBuilder) OrIn(column string, value ...interface{}) *QueryBuilder
- func (query *QueryBuilder) OrIsNULL(column string) *QueryBuilder
- func (query *QueryBuilder) OrIsNotNULL(column string) *QueryBuilder
- func (query *QueryBuilder) OrLike(column string, value interface{}) *QueryBuilder
- func (query *QueryBuilder) OrNotEqual(column string, value interface{}) *QueryBuilder
- func (query *QueryBuilder) OrNotIn(column string, value ...interface{}) *QueryBuilder
- func (query *QueryBuilder) OrWhere(column string, value ...interface{}) *QueryBuilder
- func (query *QueryBuilder) OrderBy(column string, direction string) *QueryBuilder
- func (query *QueryBuilder) QueryRow(sql string, args ...interface{}) *Row
- func (query *QueryBuilder) QueryRowSQL(sql string, args ...interface{}) string
- func (query *QueryBuilder) QueryRows(sql string, args ...interface{}) *Rows
- func (query *QueryBuilder) QueryRowsSQL(sql string, args ...interface{}) string
- func (query *QueryBuilder) Replace(datas ...interface{}) (int64, error)
- func (query *QueryBuilder) ReplaceSQL(datas ...interface{}) string
- func (query *QueryBuilder) RightJoin(tablename string, on string) *QueryBuilder
- func (query *QueryBuilder) Row() *Row
- func (query *QueryBuilder) RowSQL() string
- func (query *QueryBuilder) Rows() *Rows
- func (query *QueryBuilder) RowsSQL() string
- func (query *QueryBuilder) Select(columns ...string) *QueryBuilder
- func (query *QueryBuilder) Skip(offset int64) *QueryBuilder
- func (query *QueryBuilder) Table(tablename ...string) *QueryBuilder
- func (query *QueryBuilder) ToSql(method string) string
- func (query *QueryBuilder) Union(unions ...QueryBuilder) *QueryBuilder
- func (query *QueryBuilder) UnionAll(unions ...QueryBuilder) *QueryBuilder
- func (query *QueryBuilder) UnionLimit(limit int64) *QueryBuilder
- func (query *QueryBuilder) UnionOffset(offset int64) *QueryBuilder
- func (query *QueryBuilder) UnionOrderBy(column string, direction string) *QueryBuilder
- func (query *QueryBuilder) Update(data interface{}) (int64, error)
- func (query *QueryBuilder) UpdateSQL(data interface{}) string
- func (query *QueryBuilder) Where(column string, value ...interface{}) *QueryBuilder
- type QueryDb
- func (querydb *QueryDb) Begin() (*QueryTx, error)
- func (querydb *QueryDb) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (querydb *QueryDb) GetLastSql() Sql
- func (querydb *QueryDb) LastSql(query string, args ...interface{})
- func (querydb *QueryDb) NewQuery(ctx context.Context) *QueryBuilder
- func (querydb *QueryDb) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- type QueryTx
- func (querytx *QueryTx) Commit() error
- func (querytx *QueryTx) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (querytx *QueryTx) GetLastSql() Sql
- func (querytx *QueryTx) LastSql(query string, args ...interface{})
- func (querytx *QueryTx) NewQuery(ctx context.Context) *QueryBuilder
- func (querytx *QueryTx) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (querytx *QueryTx) Rollback() error
- type Row
- type Rows
- type Sql
Constants ¶
const ( BETWEEN = "BETWEEN" NOTBETWEEN = "NOT BETWEEN" IN = "IN" NOTIN = "NOT IN" AND = "AND" OR = "OR" ISNULL = "IS NULL" ISNOTNULL = "IS NOT NULL" EQUAL = "=" NOTEQUAL = "!=" LIKE = "LIKE" JOIN = "JOIN" INNERJOIN = "INNER JOIN" LEFTJOIN = "LEFT JOIN" RIGHTJOIN = "RIGHT JOIN" UNION = "UNION" UNIONALL = "UNION ALL" DESC = "DESC" ASC = "ASC" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Username string //账号 root Password string //密码 Host string //host localhost Port string //端口 3306 Database string //默认连接数据库 ReadTimeout int WriteTimeout int LoadBalance string //负载均衡 }
Config 数据库配置
type Connection ¶
type Connection interface { Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) NewQuery(ctx context.Context) *QueryBuilder GetLastSql() Sql LastSql(query string, args ...interface{}) }
Connection 链接
type Grammar ¶
type Grammar struct {
// contains filtered or unexported fields
}
Grammar sql 语法
func (Grammar) InsertUpdate ¶
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy 代理
func (*Proxy) SetNameSpace ¶
SetNameSpace 设置组
type QueryBuilder ¶
type QueryBuilder struct {
// contains filtered or unexported fields
}
QueryBuilder 查询构造器
func (*QueryBuilder) Between ¶
func (query *QueryBuilder) Between(column string, value1 interface{}, value2 interface{}) *QueryBuilder
Between 构造Between
func (*QueryBuilder) Equal ¶
func (query *QueryBuilder) Equal(column string, value interface{}) *QueryBuilder
Equal 构造等于
func (*QueryBuilder) Exec ¶
func (query *QueryBuilder) Exec(sql string, args ...interface{}) (int64, error)
Exec 原始SQl语句执行
func (*QueryBuilder) ExecSQL ¶
func (query *QueryBuilder) ExecSQL(sql string, args ...interface{}) string
Exec 原始SQl语句执行
func (*QueryBuilder) GroupBy ¶
func (query *QueryBuilder) GroupBy(groups ...string) *QueryBuilder
GroupBy .
func (*QueryBuilder) In ¶
func (query *QueryBuilder) In(column string, value ...interface{}) *QueryBuilder
In 构造 in语句
func (*QueryBuilder) InnerJoin ¶
func (query *QueryBuilder) InnerJoin(tablename string, on string) *QueryBuilder
func (*QueryBuilder) Insert ¶
func (query *QueryBuilder) Insert(data interface{}) (int64, error)
Insert 插入数据
func (*QueryBuilder) InsertSQL ¶
func (query *QueryBuilder) InsertSQL(data interface{}) string
InsertSQL 获取SQL语句
func (*QueryBuilder) InsertUpdate ¶
func (query *QueryBuilder) InsertUpdate(insert interface{}, update interface{}) (int64, error)
InsertUpdate
func (*QueryBuilder) InsertUpdateSQL ¶
func (query *QueryBuilder) InsertUpdateSQL(insert interface{}, update interface{}) string
InsertUpdate
func (*QueryBuilder) IsNULL ¶
func (query *QueryBuilder) IsNULL(column string) *QueryBuilder
IsNULL .
func (*QueryBuilder) IsNotNULL ¶
func (query *QueryBuilder) IsNotNULL(column string) *QueryBuilder
IsNotNULL .
func (*QueryBuilder) Join ¶
func (query *QueryBuilder) Join(tablename string, on string) *QueryBuilder
Join .
func (*QueryBuilder) LeftJoin ¶
func (query *QueryBuilder) LeftJoin(tablename string, on string) *QueryBuilder
LeftJoin .
func (*QueryBuilder) Like ¶
func (query *QueryBuilder) Like(column string, value interface{}) *QueryBuilder
Like .
func (*QueryBuilder) MultiInsert ¶
func (query *QueryBuilder) MultiInsert(datas ...interface{}) (int64, error)
MultiInsert 批量插入
func (*QueryBuilder) MultiInsertSQL ¶
func (query *QueryBuilder) MultiInsertSQL(datas ...interface{}) string
MultiInsertSQL 批量插入
func (*QueryBuilder) NotBetween ¶
func (query *QueryBuilder) NotBetween(column string, value1 interface{}, value2 interface{}) *QueryBuilder
NotBetween 构造不Not Between
func (*QueryBuilder) NotEqual ¶
func (query *QueryBuilder) NotEqual(column string, value interface{}) *QueryBuilder
NotEqual 构造不等于
func (*QueryBuilder) NotIn ¶
func (query *QueryBuilder) NotIn(column string, value ...interface{}) *QueryBuilder
NotIn .
func (*QueryBuilder) NotOrBetween ¶
func (query *QueryBuilder) NotOrBetween(column string, value1 interface{}, value2 interface{}) *QueryBuilder
NotOrBetween 构造 Not Between OR Not Between
func (*QueryBuilder) Offset ¶
func (query *QueryBuilder) Offset(offset int64) *QueryBuilder
Offset .
func (*QueryBuilder) OrBetween ¶
func (query *QueryBuilder) OrBetween(column string, value1 interface{}, value2 interface{}) *QueryBuilder
OrBetween 构造 或者 Between
func (*QueryBuilder) OrEqual ¶
func (query *QueryBuilder) OrEqual(column string, value interface{}) *QueryBuilder
OrEqual 构造或者等于
func (*QueryBuilder) OrIn ¶
func (query *QueryBuilder) OrIn(column string, value ...interface{}) *QueryBuilder
OrIn orin语句
func (*QueryBuilder) OrIsNULL ¶
func (query *QueryBuilder) OrIsNULL(column string) *QueryBuilder
OrIsNULL .
func (*QueryBuilder) OrIsNotNULL ¶
func (query *QueryBuilder) OrIsNotNULL(column string) *QueryBuilder
OrIsNotNULL .
func (*QueryBuilder) OrLike ¶
func (query *QueryBuilder) OrLike(column string, value interface{}) *QueryBuilder
OrLike .
func (*QueryBuilder) OrNotEqual ¶
func (query *QueryBuilder) OrNotEqual(column string, value interface{}) *QueryBuilder
OrNotEqual 构造或者不等于
func (*QueryBuilder) OrNotIn ¶
func (query *QueryBuilder) OrNotIn(column string, value ...interface{}) *QueryBuilder
OrNotIn .
func (*QueryBuilder) OrWhere ¶
func (query *QueryBuilder) OrWhere(column string, value ...interface{}) *QueryBuilder
OrWhere 构造OR条件
func (*QueryBuilder) OrderBy ¶
func (query *QueryBuilder) OrderBy(column string, direction string) *QueryBuilder
OrderBy .
func (*QueryBuilder) QueryRow ¶
func (query *QueryBuilder) QueryRow(sql string, args ...interface{}) *Row
func (*QueryBuilder) QueryRowSQL ¶
func (query *QueryBuilder) QueryRowSQL(sql string, args ...interface{}) string
func (*QueryBuilder) QueryRows ¶
func (query *QueryBuilder) QueryRows(sql string, args ...interface{}) *Rows
func (*QueryBuilder) QueryRowsSQL ¶
func (query *QueryBuilder) QueryRowsSQL(sql string, args ...interface{}) string
func (*QueryBuilder) Replace ¶
func (query *QueryBuilder) Replace(datas ...interface{}) (int64, error)
Replace 替换
func (*QueryBuilder) ReplaceSQL ¶
func (query *QueryBuilder) ReplaceSQL(datas ...interface{}) string
ReplaceSQL 替换
func (*QueryBuilder) RightJoin ¶
func (query *QueryBuilder) RightJoin(tablename string, on string) *QueryBuilder
RightJoin .
func (*QueryBuilder) RowSQL ¶
func (query *QueryBuilder) RowSQL() string
func (*QueryBuilder) RowsSQL ¶
func (query *QueryBuilder) RowsSQL() string
func (*QueryBuilder) Select ¶
func (query *QueryBuilder) Select(columns ...string) *QueryBuilder
Select 查询字段
func (*QueryBuilder) Table ¶
func (query *QueryBuilder) Table(tablename ...string) *QueryBuilder
Table 设置操作的表名称
func (*QueryBuilder) Union ¶
func (query *QueryBuilder) Union(unions ...QueryBuilder) *QueryBuilder
Union .
func (*QueryBuilder) UnionAll ¶
func (query *QueryBuilder) UnionAll(unions ...QueryBuilder) *QueryBuilder
UnionAll .
func (*QueryBuilder) UnionLimit ¶
func (query *QueryBuilder) UnionLimit(limit int64) *QueryBuilder
UnionLimit .
func (*QueryBuilder) UnionOffset ¶
func (query *QueryBuilder) UnionOffset(offset int64) *QueryBuilder
UnionOffset .
func (*QueryBuilder) UnionOrderBy ¶
func (query *QueryBuilder) UnionOrderBy(column string, direction string) *QueryBuilder
UnionOrderBy .
func (*QueryBuilder) Update ¶
func (query *QueryBuilder) Update(data interface{}) (int64, error)
Update 更新
func (*QueryBuilder) UpdateSQL ¶
func (query *QueryBuilder) UpdateSQL(data interface{}) string
UpdateSQL 更新
func (*QueryBuilder) Where ¶
func (query *QueryBuilder) Where(column string, value ...interface{}) *QueryBuilder
Where 构造条件语句
type QueryDb ¶
type QueryDb struct {
// contains filtered or unexported fields
}
QueryDb mysql 配置
func (*QueryDb) Exec ¶
func (querydb *QueryDb) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
Exec 复用执行语句
type QueryTx ¶
type QueryTx struct {
// contains filtered or unexported fields
}
QueryTx 事务
func (*QueryTx) Exec ¶
func (querytx *QueryTx) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
Exec 复用执行语句
func (*QueryTx) NewQuery ¶
func (querytx *QueryTx) NewQuery(ctx context.Context) *QueryBuilder
NewQuery 生成一个新的查询构造器
type Row ¶
type Row struct {
// contains filtered or unexported fields
}
Row 获取记录
func (*Row) ToInterface ¶
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows get data
func (*Rows) ToInterface ¶
[]map[interface{}]interface{}