mysql

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBConf

type DBConf struct {

	// 以下配置关于dsn
	WriteTimeout         string `json:"write_timeout"`          // 写超时时间
	Loc                  string `json:"loc"`                    // 时区
	Port                 int    `json:"port"`                   // 端口
	ReadTimeout          string `json:"read_timeout"`           // 读超时时间
	Charset              string `json:"charset"`                // 字符集
	ParseTime            bool   `json:"parse_time"`             // 是否解析时间
	Protocol             string `json:"protocol"`               // 传输协议
	Dsn                  string `json:"dsn"`                    // 直接传递dsn,如果传递了,其他关于dsn的配置均无效
	Database             string `json:"database"`               // 数据库
	Collation            string `json:"collation"`              // 字符序
	Timeout              string `json:"timeout"`                // 连接超时时间
	Username             string `json:"username"`               // 用户名
	Password             string `json:"password"`               // 密码
	Driver               string `json:"driver"`                 // 驱动
	Host                 string `json:"host"`                   // 数据库地址
	AllowNativePasswords bool   `json:"allow_native_passwords"` // 是否允许nativePassword

	// 以下配置关于连接池
	MaxIdleConnections    int           `json:"max-idle-connections,omitempty"`     // 最大空闲连接数
	MaxOpenConnections    int           `json:"max-open-connections,omitempty"`     // 最大连接数
	MaxConnectionLifeTime time.Duration `json:"max-connection-life-time,omitempty"` // 连接最大生命周期
	MaxConnectionIdletime time.Duration `json:"conn_max_idletime"`                  // 空闲最大生命周期

}

关系型数据库的配置

func NewMySQLOptions

func NewMySQLOptions() *DBConf

NewMySQLOptions create a `zero` value instance.

func (*DBConf) FormatDSN

func (conf *DBConf) FormatDSN() (string, error)

Jump to

Keyboard shortcuts

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