mysql

package
v0.0.0-...-750a8a5 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

Close method

func Conn

func Conn() *gorm.DB

获取Mysql连接

func Init

func Init(mysqlConfig Config)

初始化数据库

Types

type Config

type Config struct {
	User        string `json:"user" yaml:"user"`                                                 // 用户名
	Password    string `json:"password" yaml:"password"`                                         // 密码
	Host        string `json:"host" yaml:"host"`                                                 // 主机地址
	Port        int    `json:"port" yaml:"port"`                                                 // 端口号
	Dbname      string `json:"dbname" yaml:"dbname"`                                             // 数据库名
	MaxIdleConn int    `json:"max_idle_conn" yaml:"max_idle_conn" mapstructure:"max_idle_conn"`  // 最大空闲连接
	MaxOpenConn int    `json:"max_open_conn" yaml:"max_open_conn" mapstructure:"max_open_conn" ` // 最大活跃连接
	Debug       bool   `json:"debug" yaml:"debug"`                                               // 是否开启Debug(开启Debug会打印数据库操作日志)
}

Mysql配置结构体

Jump to

Keyboard shortcuts

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