mysql

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SqlDB *sql.DB
)

Functions

func Exec

func Exec(query string, args ...interface{}) sql.Result

func InitDB

func InitDB(username string, password string, port string, ip string, databaseName string)

只会执行一次在执行程序启动的时候

func Query

func Query(query string, args ...interface{}) ([]map[string]interface{}, *sql.Rows)

func QueryWithConnection

func QueryWithConnection(con string, query string, args ...interface{}) ([]map[string]interface{}, *sql.Rows)

func SetColVarType

func SetColVarType(colVar *[]interface{}, i int, typeName string)

func SetResultValue

func SetResultValue(result *map[string]interface{}, index string, colVar interface{}, typeName string)

func WithTransaction

func WithTransaction(fn TxFn) (err error, res map[string]interface{})

Types

type SqlTxStruct

type SqlTxStruct struct {
	Tx *sql.Tx
}

func BeginTransactions

func BeginTransactions() *SqlTxStruct

func BeginTransactionsByLevel

func BeginTransactionsByLevel() *SqlTxStruct

func (*SqlTxStruct) Exec

func (SqlTx *SqlTxStruct) Exec(query string, args ...interface{}) (sql.Result, error)

func (*SqlTxStruct) Query

func (SqlTx *SqlTxStruct) Query(query string, args ...interface{}) ([]map[string]interface{}, error)

type TxFn

type TxFn func(*SqlTxStruct) (error, map[string]interface{})

Jump to

Keyboard shortcuts

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