imysql

package
v0.0.0-...-523602a Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GormOpenDB

func GormOpenDB(cfg *MysqlConf, autoMigrates ...interface{}) (err error)

开启Gorm数据库

func New

func New(c *MysqlConf, autoMigrates ...interface{}) *gorm.DB

Types

type GormConfig

type GormConfig struct {
	// 方言
	Dialect string
	// 连接参数
	DialectArgs interface{}
	// 是否开启DEBUG(耗性能)
	IsDebug bool
	// 连接池的空闲数大小
	MaxIdleConns int
	// 最大打开连接数
	MaxOpenConns int
	// 连接最大存活时间
	ConnMaxLifetime time.Duration
}

type MysqlConf

type MysqlConf struct {
	Debug       bool   `yaml:"debug" json:"debug"`
	Port        int16  `yaml:"port" json:"port"`
	MaxIdleConn int16  `yaml:"max_idle_conn" json:"max_idle_conn"`
	MaxOpenConn int16  `yaml:"max_open_conn" json:"max_open_conn"`
	UserName    string `yaml:"username" json:"user_name"`
	Password    string `yaml:"password" json:"password"`
	Host        string `yaml:"host" json:"host"`
	DataBase    string `yaml:"database" json:"data_base"`
}

Jump to

Keyboard shortcuts

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