Documentation ¶
Index ¶
Constants ¶
View Source
const ( // 数据库类型 SqlTypeMySQL = "mysql" // MySQL类型数据库 SqlTypeSqlite = "sqlite" // SQLite类型数据库 )
Variables ¶
This section is empty.
Functions ¶
func DoUpdate ¶
func DoUpdate( db SQLCommon, tableName string, data [][]interface{}, options UpdateMultiOptions, ) (err error)
插入多条增量更新的数据
func DoUpdateOne ¶
func DoUpdateOne( db SQLCommon, tableName string, data []interface{}, options UpdateOptions, ) (err error)
插入单条数据
Types ¶
type FetchOptions ¶
type FetchOptions struct { IgnoreFields []string // 忽略的列名称 PageNumber int // 分页获取增量的页码,从1开始 PageSize int // 分页获取增量的页大小 UpdateTimeFieldName string // 更新时间所在列的列名称 LastUpdateTime int64 // 从哪个时间戳开始查询,这是大于的关系 WhereSqlStmt string // 自定义SQL查询语句的Where子句 WhereSqlArgs []interface{} // 自定义SQL查询语句的Where子句的参数列表 }
获取增量数据时的配置信息
type FetchResult ¶
type FetchResult struct { Columns []string `json:"columns"` // 列名称 Data [][]interface{} `json:"data"` // 待同步的数据,每一行是一条数据,与列名称一一对应 Count int64 `json:"count"` // 数据的数量 }
获取增量数据的返回结果
func DoFetch ¶
func DoFetch( db SQLCommon, tableName string, options FetchOptions, ) (rsp FetchResult, err error)
获取增量更新的数据
type SQLCommon ¶
type SQLCommon interface { Exec(query string, args ...interface{}) (sql.Result, error) Prepare(query string) (*sql.Stmt, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row }
原始SQL的接口
type UpdateMultiOptions ¶
type UpdateMultiOptions struct { UpdateOptions BatchCount int // 一次批量插入的条数,用于加快执行速度 }
插入多条数据时的配置信息
type UpdateOptions ¶
type UpdateOptions struct { Columns []string // 列名称 TimeFields []string // time.Time时间类型的列名称列表 FixedFields map[string]interface{} // 固定的插入列 UniqueFields []string // 唯一键或主键的列名称列表 SqlType string // 数据库类型,目前支持MySQL和SQLite }
插入数据时的配置信息
func (UpdateOptions) IsMySQL ¶
func (m UpdateOptions) IsMySQL() bool
func (UpdateOptions) IsSqlite ¶
func (m UpdateOptions) IsSqlite() bool
Click to show internal directories.
Click to hide internal directories.