Documentation ¶
Index ¶
- Constants
- func NewSQLConn(driverName, server string, opt *Opt) (*sql.DB, error)
- type Builder
- func (builder *Builder) Between(column string, value1 interface{}, value2 interface{}) *Builder
- func (builder *Builder) Count() (int64, error)
- func (builder *Builder) Delete() (int64, error)
- func (builder *Builder) DeleteSQL() string
- func (builder *Builder) Distinct() *Builder
- func (builder *Builder) Equal(column string, value interface{}) *Builder
- func (builder *Builder) Exec(sql string, args ...interface{}) (int64, error)
- func (builder *Builder) ExecSQL(sql string, args ...interface{}) string
- func (builder *Builder) Greater(column string, value interface{}) *Builder
- func (builder *Builder) GreaterEqual(column string, value interface{}) *Builder
- func (builder *Builder) GroupBy(groups ...string) *Builder
- func (builder *Builder) In(column string, value ...interface{}) *Builder
- func (builder *Builder) InnerJoin(tablename string, on string) *Builder
- func (builder *Builder) Insert(data interface{}) (int64, error)
- func (builder *Builder) InsertSQL(data interface{}) string
- func (builder *Builder) InsertUpdate(insert interface{}, update interface{}) (int64, error)
- func (builder *Builder) InsertUpdateSQL(insert interface{}, update interface{}) string
- func (builder *Builder) IsNULL(column string) *Builder
- func (builder *Builder) IsNotNULL(column string) *Builder
- func (builder *Builder) IsZero(v reflect.Value) bool
- func (builder *Builder) Join(tablename string, on string) *Builder
- func (builder *Builder) LeftJoin(tablename string, on string) *Builder
- func (builder *Builder) Less(column string, value interface{}) *Builder
- func (builder *Builder) LessEqual(column string, value interface{}) *Builder
- func (builder *Builder) Like(column string, value interface{}) *Builder
- func (builder *Builder) Limit(limit int64) *Builder
- func (builder *Builder) MultiInsert(datas ...interface{}) (int64, error)
- func (builder *Builder) MultiInsertSQL(datas ...interface{}) string
- func (builder *Builder) NotBetween(column string, value1 interface{}, value2 interface{}) *Builder
- func (builder *Builder) NotEqual(column string, value interface{}) *Builder
- func (builder *Builder) NotIn(column string, value ...interface{}) *Builder
- func (builder *Builder) NotOrBetween(column string, value1 interface{}, value2 interface{}) *Builder
- func (builder *Builder) Offset(offset int64) *Builder
- func (builder *Builder) OrBetween(column string, value1 interface{}, value2 interface{}) *Builder
- func (builder *Builder) OrEqual(column string, value interface{}) *Builder
- func (builder *Builder) OrIn(column string, value ...interface{}) *Builder
- func (builder *Builder) OrIsNULL(column string) *Builder
- func (builder *Builder) OrIsNotNULL(column string) *Builder
- func (builder *Builder) OrLike(column string, value interface{}) *Builder
- func (builder *Builder) OrNotEqual(column string, value interface{}) *Builder
- func (builder *Builder) OrNotIn(column string, value ...interface{}) *Builder
- func (builder *Builder) OrWhere(column string, value ...interface{}) *Builder
- func (builder *Builder) OrderBy(column string, direction string) *Builder
- func (builder *Builder) QueryRow(sql string, args ...interface{}) *Row
- func (builder *Builder) QueryRowSQL(sql string, args ...interface{}) string
- func (builder *Builder) QueryRows(sql string, args ...interface{}) *Rows
- func (builder *Builder) QueryRowsSQL(sql string, args ...interface{}) string
- func (builder *Builder) Replace(datas ...interface{}) (int64, error)
- func (builder *Builder) ReplaceSQL(datas ...interface{}) string
- func (builder *Builder) RightJoin(tablename string, on string) *Builder
- func (builder *Builder) Row() *Row
- func (builder *Builder) RowSQL() string
- func (builder *Builder) Rows() *Rows
- func (builder *Builder) RowsSQL() string
- func (builder *Builder) Select(columns ...string) *Builder
- func (builder *Builder) Skip(offset int64) *Builder
- func (builder *Builder) Table(tableName ...string) *Builder
- func (builder *Builder) ToSQL(method string) string
- func (builder *Builder) Union(unions ...Builder) *Builder
- func (builder *Builder) UnionAll(unions ...Builder) *Builder
- func (builder *Builder) UnionLimit(limit int64) *Builder
- func (builder *Builder) UnionOffset(offset int64) *Builder
- func (builder *Builder) UnionOrderBy(column string, direction string) *Builder
- func (builder *Builder) Update(data interface{}) (int64, error)
- func (builder *Builder) UpdateSQL(data interface{}) string
- func (builder *Builder) Where(column string, value ...interface{}) *Builder
- type Connection
- type Epr
- type Grammar
- type Opt
- type Query
- func (query *Query) Begin() (*Transaction, error)
- func (query *Query) Exec(ctx context.Context, querySQL string, args ...interface{}) (sql.Result, error)
- func (query *Query) LastSQL(querySQL string, args ...interface{})
- func (query *Query) NewBuilder(ctx context.Context) *Builder
- func (query *Query) Query(ctx context.Context, querySQL string, args ...interface{}) (*sql.Rows, error)
- func (query *Query) SQLRaw() string
- type Row
- type Rows
- type SQL
- type Transaction
- func (query *Transaction) Commit() error
- func (query *Transaction) Exec(ctx context.Context, querySQL string, args ...interface{}) (sql.Result, error)
- func (query *Transaction) LastSQL(querySQL string, args ...interface{})
- func (query *Transaction) NewBuilder(ctx context.Context) *Builder
- func (query *Transaction) Query(ctx context.Context, querySQL string, args ...interface{}) (*sql.Rows, error)
- func (query *Transaction) Rollback() error
- func (query *Transaction) SQLRaw() string
Constants ¶
View Source
const ( BETWEEN = "BETWEEN" NOTBETWEEN = "NOT BETWEEN" IN = "IN" NOTIN = "NOT IN" AND = "AND" OR = "OR" ISNULL = "IS NULL" ISNOTNULL = "IS NOT NULL" EQUAL = "=" NOTEQUAL = "!=" GREATER = ">" GREATEREQUAL = ">=" LESS = "<" LESSEQUAL = "<=" LIKE = "LIKE" JOIN = "JOIN" INNERJOIN = "INNER JOIN" LEFTJOIN = "LEFT JOIN" RIGHTJOIN = "RIGHT JOIN" UNION = "UNION" UNIONALL = "UNION ALL" DESC = "DESC" ASC = "ASC" )
BETWEEN ...
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶ added in v3.1.9
type Builder struct {
// contains filtered or unexported fields
}
Builder 查询构造器
func (*Builder) GreaterEqual ¶ added in v3.2.8
Greater 构造大于等于
func (*Builder) InsertUpdate ¶ added in v3.1.9
InsertUpdate ...
func (*Builder) InsertUpdateSQL ¶ added in v3.1.9
InsertUpdateSQL ...
func (*Builder) MultiInsert ¶ added in v3.1.9
MultiInsert 批量插入
func (*Builder) MultiInsertSQL ¶ added in v3.1.9
MultiInsertSQL 批量插入
func (*Builder) NotBetween ¶ added in v3.1.9
NotBetween 构造不Not Between
func (*Builder) NotOrBetween ¶ added in v3.1.9
func (builder *Builder) NotOrBetween(column string, value1 interface{}, value2 interface{}) *Builder
NotOrBetween 构造 Not Between OR Not Between
func (*Builder) OrIsNotNULL ¶ added in v3.1.9
OrIsNotNULL .
func (*Builder) OrNotEqual ¶ added in v3.1.9
OrNotEqual 构造或者不等于
func (*Builder) QueryRowSQL ¶ added in v3.1.9
QueryRowSQL ...
func (*Builder) QueryRowsSQL ¶ added in v3.1.9
QueryRowsSQL ...
func (*Builder) ReplaceSQL ¶ added in v3.1.9
ReplaceSQL 替换
func (*Builder) UnionLimit ¶ added in v3.1.9
UnionLimit .
func (*Builder) UnionOffset ¶ added in v3.1.9
UnionOffset .
func (*Builder) UnionOrderBy ¶ added in v3.1.9
UnionOrderBy .
type Connection ¶
type Connection interface { Exec(ctx context.Context, querySQL string, args ...interface{}) (sql.Result, error) Query(ctx context.Context, querySQL string, args ...interface{}) (*sql.Rows, error) NewBuilder(ctx context.Context) *Builder SQLRaw() string LastSQL(querySQL string, args ...interface{}) }
Connection 链接
type Opt ¶
type Opt struct { MaxLifetime time.Duration //连接池里面的连接最大存活时长 MaxIdleTime time.Duration //连接池里面的连接最大空闲时长 MaxOpenConns int //连接池最多同时打开的连接数 MaxIdleConns int //连接池里最大空闲连接数。必须要比maxOpenConns小 }
Opt ...
type Query ¶ added in v3.1.8
type Query struct { DB *sql.DB SQL SQL DriverName string DisableMetric bool // 关闭指标采集 DisableTrace bool // 关闭链路追踪 Prepare bool DBName string Addr string Func string // 上个函数调用的函数名称 Path string // 上个函数调用的函数位置 }
Query 构造查询
func (*Query) Begin ¶ added in v3.1.9
func (query *Query) Begin() (*Transaction, error)
Begin 开启一个事务
func (*Query) Exec ¶ added in v3.1.8
func (query *Query) Exec(ctx context.Context, querySQL string, args ...interface{}) (sql.Result, error)
Exec 复用执行语句
func (*Query) NewBuilder ¶ added in v3.1.9
NewBuilder 生成一个新的查询构造器
type Row ¶
type Row struct {
// contains filtered or unexported fields
}
Row 获取记录
func (*Row) ToInterface ¶
ToInterface ...
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows get data
func (*Rows) ToInterface ¶
ToInterface []map[interface{}]interface{}
type Transaction ¶ added in v3.1.9
type Transaction struct { Transaction *sql.Tx SQL SQL DriverName string DisableMetric bool // 关闭指标采集 DisableTrace bool // 关闭链路追踪 Prepare bool DBName string Addr string Func string // 上个函数调用的函数名称 Path string // 上个函数调用的函数位置 }
Transaction 事务
func (*Transaction) Exec ¶ added in v3.1.9
func (query *Transaction) Exec(ctx context.Context, querySQL string, args ...interface{}) (sql.Result, error)
Exec 复用执行语句
func (*Transaction) LastSQL ¶ added in v3.1.9
func (query *Transaction) LastSQL(querySQL string, args ...interface{})
LastSQL ...
func (*Transaction) NewBuilder ¶ added in v3.1.9
func (query *Transaction) NewBuilder(ctx context.Context) *Builder
NewBuilder 生成一个新的查询构造器
func (*Transaction) Query ¶ added in v3.1.9
func (query *Transaction) Query(ctx context.Context, querySQL string, args ...interface{}) (*sql.Rows, error)
Query 复用查询语句
func (*Transaction) Rollback ¶ added in v3.1.9
func (query *Transaction) Rollback() error
Rollback 事务回滚
Click to show internal directories.
Click to hide internal directories.