mysqltool

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DBMock sqlmock.Sqlmock

Functions

func AssemberInsertOrUpdateSQL

func AssemberInsertOrUpdateSQL(
	part1Sql string, part2Sql string, part3Sql string, fieldSql string,
	elemCount uint32,
	sqlRet *string,
) error

组装 insert ... update 语句

func AssembleInRangeSQL

func AssembleInRangeSQL(
	part1Sql string, part2Sql string,
	part1Args *[]interface{}, listArgs *[]uint64, part2Args *[]interface{},
	sqlRet *string, fieldArgs *[]interface{},
)

组装 in () 类型的SQL语句及参数

func AssembleInRangeSQLTemplate

func AssembleInRangeSQLTemplate(
	part1Sql string, part2Sql string,
	part1Args *[]interface{}, listArgs *[]interface{}, part2Args *[]interface{},
	sqlRet *string, fieldArgs *[]interface{},
)

组装 in () 类型的SQL语句及参数

func ConnectToDefaultMySQL

func ConnectToDefaultMySQL()

连接默认的MySQL数据库

func DefaultMySQL

func DefaultMySQL() *sqlx.DB

获取默认的MySQL实例

func InitMySQLClient

func InitMySQLClient(sqlConf *extconfig.MySQLAddress, setting string, targetDB **sqlx.DB)

初始化MySQL连接

func ReadDBByPage

func ReadDBByPage(queryFn QueryFn, readFn ReadRowFn) error

分页读取MySQL表, 有总记录数限制

func ReadDBByPageWithLimit

func ReadDBByPageWithLimit(queryFn QueryFn, readFn ReadRowFn, totalCountLimit int) error

分页读取MySQL表,可设置记录数上限

func Setup

func Setup()

配置测试环境

func Teardown

func Teardown()

清理测试环境

Types

type QueryFn

type QueryFn func(offset int, limit int) (*sqlx.Rows, error)

分页读取的函数框架

type ReadRowFn

type ReadRowFn func(*sqlx.Rows) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL