Documentation ¶
Index ¶
- Constants
- func Caller(skip int) map[string]string
- func Format(query string, args ...any) (string, error)
- func ResultAccept(err error) error
- type Builder
- func (builder *Builder) And() *Builder
- func (builder *Builder) Between(column string, value1 any, value2 any) *Builder
- func (builder *Builder) Count() (sql string, args []any, err error)
- func (builder *Builder) Delete() (sql string, args []any, err error)
- func (builder *Builder) Distinct() *Builder
- func (builder *Builder) Equal(column string, value any) *Builder
- func (builder *Builder) FirstLike(column string, value any) *Builder
- func (builder *Builder) Greater(column string, value any) *Builder
- func (builder *Builder) GreaterEqual(column string, value any) *Builder
- func (builder *Builder) GroupBy(groups ...string) *Builder
- func (builder *Builder) In(column string, value ...any) *Builder
- func (builder *Builder) InnerJoin(tablename string, on string) *Builder
- func (builder *Builder) Insert(data any) (sql string, args []any, err error)
- func (builder *Builder) InsertUpdate(insert any, update any) (sql string, args []any, err error)
- 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) JsonContainsMany(column string, value ...any) *Builder
- func (builder *Builder) JsonContainsObject(column string, value ...any) *Builder
- func (builder *Builder) JsonContainsOne(column string, value any) *Builder
- func (builder *Builder) JsonExtract(column string, value ...any) *Builder
- func (builder *Builder) LeftBracket() *Builder
- func (builder *Builder) LeftJoin(tablename string, on string) *Builder
- func (builder *Builder) Less(column string, value any) *Builder
- func (builder *Builder) LessEqual(column string, value any) *Builder
- func (builder *Builder) Like(column string, value any) *Builder
- func (builder *Builder) Limit(limit int64) *Builder
- func (builder *Builder) MultiInsert(data ...any) (sql string, args []any, err error)
- func (builder *Builder) NotBetween(column string, value1 any, value2 any) *Builder
- func (builder *Builder) NotEqual(column string, value any) *Builder
- func (builder *Builder) NotIn(column string, value ...any) *Builder
- func (builder *Builder) NotOrBetween(column string, value1 any, value2 any) *Builder
- func (builder *Builder) Offset(offset int64) *Builder
- func (builder *Builder) OrBetween(column string, value1 any, value2 any) *Builder
- func (builder *Builder) OrEqual(column string, value any) *Builder
- func (builder *Builder) OrIn(column string, value ...any) *Builder
- func (builder *Builder) OrIsNULL(column string) *Builder
- func (builder *Builder) OrIsNotNULL(column string) *Builder
- func (builder *Builder) OrLike(column string, value any) *Builder
- func (builder *Builder) OrNotEqual(column string, value any) *Builder
- func (builder *Builder) OrNotIn(column string, value ...any) *Builder
- func (builder *Builder) OrWhere(column string, value ...any) *Builder
- func (builder *Builder) OrderBy(column string, direction string) *Builder
- func (builder *Builder) Replace(data ...any) (sql string, args []any, err error)
- func (builder *Builder) RightBracket() *Builder
- func (builder *Builder) RightJoin(tablename string, on string) *Builder
- func (builder *Builder) Row() (sql string, args []any, err error)
- func (builder *Builder) Rows() (sql string, args []any, err error)
- 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 any) (sql string, args []any, err error)
- func (builder *Builder) Where(column string, value ...any) *Builder
- type Client
- type Epr
- type Grammar
- type Option
- func WithAddr(addr []string) Option
- func WithCharset(charset string) Option
- func WithCompress(compress bool) Option
- func WithDatabase(database string) Option
- func WithDialTimeout(dialTimeout string) Option
- func WithDisableDebug(disableDebug bool) Option
- func WithDisableMetric(disableMetric bool) Option
- func WithDisablePrepare(disablePrepare bool) Option
- func WithDisableTrace(disableTrace bool) Option
- func WithDriverName(driverName string) Option
- func WithHost(host string) Option
- func WithMaxExecutionTime(maxExecutionTime string) Option
- func WithMaxIdleConns(maxIdleConns int) Option
- func WithMaxIdleTime(maxIdleTime time.Duration) Option
- func WithMaxLifetime(maxLifetime time.Duration) Option
- func WithMaxOpenConns(maxOpenConns int) Option
- func WithOpenStrategy(openStrategy string) Option
- func WithParseTime(parseTime bool) Option
- func WithPassword(password string) Option
- func WithPort(port string) Option
- func WithTimeZone(timeZone string) Option
- func WithUsername(username string) Option
- type Row
- type Rows
- type Session
- type SqlConn
- type SqlOption
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" LeftBracket = "(" RightBracket = ")" And = "AND" JsonContainsOne = "JsonContainsOne" JsonContainsMany = "JsonContainsMany" JsonExtract = "JsonExtract" JsonContainsObject = "JsonContainsObject" )
BETWEEN ...
Variables ¶
This section is empty.
Functions ¶
func ResultAccept ¶ added in v3.5.6
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder 查询构造器
func (*Builder) GreaterEqual ¶
Greater 构造大于等于
func (*Builder) InsertUpdate ¶
InsertUpdate ...
func (*Builder) JsonContainsMany ¶ added in v3.6.6
JsonContainsMany .
func (*Builder) JsonContainsObject ¶ added in v3.6.7
func (*Builder) JsonContainsOne ¶ added in v3.6.6
JsonContainsOne .
func (*Builder) JsonExtract ¶ added in v3.6.7
func (*Builder) LeftBracket ¶ added in v3.6.5
func (*Builder) MultiInsert ¶
MultiInsert 批量插入
func (*Builder) NotBetween ¶
NotBetween 构造不Not Between
func (*Builder) NotOrBetween ¶
NotOrBetween 构造 Not Between OR Not Between
func (*Builder) OrIsNotNULL ¶
OrIsNotNULL .
func (*Builder) OrNotEqual ¶
OrNotEqual 构造或者不等于
func (*Builder) RightBracket ¶ added in v3.6.5
func (*Builder) UnionOffset ¶
UnionOffset .
func (*Builder) UnionOrderBy ¶
UnionOrderBy .
type Client ¶
type Client struct { Username string // 账号 root Password string // 密码 Host string // host localhost mysql Port string // 端口 3306 Charset string // 字符编码 utf8mb4 Database string // 默认连接数据库 TimeZone string // 数据库时区 MaxOpenConns int // 连接池最多同时打开的连接数 MaxIdleConns int // 连接池里最大空闲连接数。必须要比maxOpenConns小 MaxLifetime time.Duration // 连接池里面的连接最大存活时长 MaxIdleTime time.Duration // 连接池里面的连接最大空闲时长 DriverName string // 驱动名称 DisableMetric bool // 关闭指标采集 DisableTrace bool // 关闭链路追踪 DisablePrepare bool // 关闭预处理 Addr []string // ip:port clickhouse DialTimeout string // 200ms clickhouse OpenStrategy string // random/in_order (default random) clickhouse Compress bool // enable lz4 compression clickhouse MaxExecutionTime string // 执行超时时间 clickhouse DisableDebug bool // 关闭 debug模式 clickhouse ParseTime bool // 是否解析时间 }
func (*Client) NewClickhouse ¶
NewClickhouse returns a clickhouse connection.
func (*Client) NewPostgres ¶
NewPostgres returns a postgres connection.
func (*Client) NewSqlClient ¶
NewSqlClient 代理
type Option ¶
type Option func(r *Client)
func WithDisablePrepare ¶
func WithMaxExecutionTime ¶
WithMaxExecutionTime 设置执行超时时间
func WithMaxIdleConns ¶
WithMaxIdleConns 设置连接池里最大空闲连接数。必须要比maxOpenConns小
func WithMaxIdleTime ¶
WithMaxIdleTime 设置连接池里面的连接最大空闲时长
func WithMaxLifetime ¶
WithMaxLifetime 设置连接池里面的连接最大存活时长
func WithMaxOpenConns ¶
WithMaxOpenConns 设置连接池最多同时打开的连接数
func WithOpenStrategy ¶
WithOpenStrategy 设置random/in_order (default random)
func WithParseTime ¶
type Session ¶
type Session interface { MultiInsert(ctx context.Context, query string, args ...any) (int64, error) Replace(ctx context.Context, query string, args ...any) (int64, error) InsertUpdate(ctx context.Context, query string, args ...any) (int64, error) Insert(ctx context.Context, query string, args ...any) (int64, error) Update(ctx context.Context, query string, args ...any) (int64, error) Delete(ctx context.Context, query string, args ...any) (int64, error) Exec(ctx context.Context, query string, args ...any) (int64, error) Count(ctx context.Context, query string, args ...any) (int64, error) QueryRow(ctx context.Context, query string, args ...any) *Row QueryRows(ctx context.Context, query string, args ...any) *Rows ExecCtx(ctx context.Context, query string, args ...any) (sql.Result, error) QueryCtx(ctx context.Context, query string, args ...any) (*sql.Rows, error) }
Session stands for raw connections or transaction sessions
Click to show internal directories.
Click to hide internal directories.