Documentation ¶
Index ¶
- Constants
- Variables
- func Create(dataSourceName string, showSQL bool) *sqlx.DB
- func ExecuteCountContent(ctx context.Context, tx ExecuteAble, query string, ...) (int64, error)
- func ExecuteLastIDContent(ctx context.Context, tx ExecuteAble, query string, ...) (int64, error)
- func GetContent(ctx context.Context, tx ExecuteAble, dest interface{}, query string, ...) (bool, error)
- func RowsContent(ctx context.Context, tx ExecuteAble, query string, ...) ([]map[string]interface{}, error)
- func SelectContent(ctx context.Context, tx ExecuteAble, dest interface{}, query string, ...) error
- func SetShowSQL(b bool)
- func Transaction(ctx context.Context, db *sqlx.DB, f func(dbTx ExecuteAble) error) error
- type ExecuteAble
Constants ¶
View Source
const ( GoTypeString = 1 GoTypeInt64 = 2 GoTypeBytes = 3 GoTypeFloat64 = 4 GoTypeTime = 5 )
数据库数据类型
Variables ¶
View Source
var TypeMySQLToGoMap = map[string]int64{
"BIT": 1,
"TEXT": 1,
"BLOB": 3,
"DATETIME": 5,
"DOUBLE": 4,
"ENUM": 1,
"FLOAT": 4,
"GEOMETRY": 1,
"MEDIUMINT": 2,
"JSON": 1,
"INT": 2,
"LONGTEXT": 1,
"LONGBLOB": 3,
"BIGINT": 2,
"MEDIUMTEXT": 1,
"MEDIUMBLOB": 3,
"DATE": 5,
"DECIMAL": 1,
"SET": 1,
"SMALLINT": 2,
"BINARY": 3,
"CHAR": 1,
"TIME": 5,
"TIMESTAMP": 5,
"TINYINT": 2,
"TINYTEXT": 1,
"TINYBLOB": 3,
"VARBINARY": 3,
"VARCHAR": 1,
"YEAR": 2,
}
TypeMySQLToGoMap 类型转换关系
Functions ¶
func ExecuteCountContent ¶
func ExecuteCountContent(ctx context.Context, tx ExecuteAble, query string, argMap map[string]interface{}) (int64, error)
ExecuteCountContent 执行sql语句返回执行个数
func ExecuteLastIDContent ¶
func ExecuteLastIDContent(ctx context.Context, tx ExecuteAble, query string, argMap map[string]interface{}) (int64, error)
ExecuteLastIDContent 执行sql语句并返回lastID
func GetContent ¶
func GetContent(ctx context.Context, tx ExecuteAble, dest interface{}, query string, argMap map[string]interface{}) (bool, error)
GetContent 执行sql查询并返回当个元素
func RowsContent ¶
func RowsContent(ctx context.Context, tx ExecuteAble, query string, argMap map[string]interface{}) ([]map[string]interface{}, error)
RowsContent 执行sql查询并返回多行
func SelectContent ¶
func SelectContent(ctx context.Context, tx ExecuteAble, dest interface{}, query string, argMap map[string]interface{}) error
SelectContent 执行sql查询并返回多行
func Transaction ¶
Transaction 执行事物
Types ¶
type ExecuteAble ¶
type ExecuteAble interface { Rebind(string) string Get(dest interface{}, query string, args ...interface{}) error Exec(query string, args ...interface{}) (sql.Result, error) Select(dest interface{}, query string, args ...interface{}) error GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row }
ExecuteAble 数据库接口
Click to show internal directories.
Click to hide internal directories.