database

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MysqlTypeToGoType = map[string]string{
	"enum":       "GoString",
	"set":        "GoString",
	"varchar":    "GoString",
	"char":       "GoString",
	"tinytext":   "GoString",
	"mediumtext": "GoString",
	"text":       "GoString",
	"longtext":   "GoString",
	"blob":       "GoString",
	"tinyblob":   "GoString",
	"mediumblob": "GoString",
	"longblob":   "GoString",
	"date":       "GoString",
	"time":       "GoString",
	"binary":     "GoString",
	"varbinary":  "GoString",
	"json":       "GoString",

	"int":                "GoInt",
	"integer":            "GoInt",
	"tinyint":            "GoInt",
	"smallint":           "GoInt",
	"mediumint":          "GoInt",
	"bigint":             "GoInt",
	"int unsigned":       "GoInt",
	"integer unsigned":   "GoInt",
	"tinyint unsigned":   "GoInt",
	"smallint unsigned":  "GoInt",
	"mediumint unsigned": "GoInt",
	"bigint unsigned":    "GoInt",
	"bit":                "GoInt",

	"float":   "GoFloat",
	"double":  "GoFloat",
	"decimal": "GoFloat",

	"bool": "GoBool",

	"datetime":  "GoTime",
	"timestamp": "GoTime",
}

MysqlTypeToGoType mysql数据库字段类型对应的go数据类型

View Source
var TimeLayout string

TimeLayout time.Parse 解析数据库时间字段到 GoTime 时的 layout,默认为 "2006-01-02 15:04:05 +0800 CST"

Functions

This section is empty.

Types

type Client

type Client struct {
	Db *sql.DB
	Tx *sql.Tx
	// contains filtered or unexported fields
}

Client ----mysql client

func GetDb

func GetDb(dsn string) (dbClient *Client, e error)

GetDb ----connection mysql

func (*Client) BaseQuery

func (c *Client) BaseQuery(query string, args ...interface{}) (rows *sql.Rows, e error)

BaseQuery ----base query

func (*Client) QueryMaps

func (c *Client) QueryMaps(query string, args ...interface{}) (res []map[string]string, e error)

QueryMaps ----query data, []map[string]string, key:database field, value:the value of database field.

type GoBool

type GoBool bool //MysqlTypeToGoType中 value=GoBool的所有数据库类型

func (*GoBool) Scan

func (s *GoBool) Scan(value interface{}) error

func (*GoBool) String

func (s *GoBool) String() string

*GoBool 实现 String() 方法

type GoFloat

type GoFloat float64 //MysqlTypeToGoType中 value=GoFloat的所有数据库类型

func (*GoFloat) Scan

func (s *GoFloat) Scan(value interface{}) error

func (*GoFloat) String

func (s *GoFloat) String() string

*GoFloat 实现 String() 方法

type GoInt

type GoInt int //MysqlTypeToGoType中 value=GoInt的所有数据库类型

func (*GoInt) Scan

func (s *GoInt) Scan(value interface{}) error

func (*GoInt) String

func (s *GoInt) String() string

*GoInt实现 String() 方法

type GoString

type GoString string //MysqlTypeToGoType中 value=GoString的所有数据库类型

func (*GoString) Scan

func (s *GoString) Scan(value interface{}) error

func (*GoString) String

func (s *GoString) String() string

*GoString 实现 String() 方法, 当格式化输出 *GoString 类型时自动调用该方法

type GoTime

type GoTime string //MysqlTypeToGoType中 value=GoTime的所有数据库类型

func (*GoTime) Scan

func (s *GoTime) Scan(value interface{}) error

func (*GoTime) String

func (s *GoTime) String() string

*GoTime 实现 String() 方法

Jump to

Keyboard shortcuts

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