mysql

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(m Mysql) (*gorm.DB, error)

func ConnectWithConfig

func ConnectWithConfig(m Mysql, cfg *gorm.Config) (*gorm.DB, error)

Types

type Mysql

type Mysql struct {
	Path         string // 服务器地址
	Port         int    `json:",default=3306"`                                               // 端口
	Config       string `json:",default=charset%3Dutf8mb4%26parseTime%3Dtrue%26loc%3DLocal"` // 高级配置
	Dbname       string // 数据库名
	Username     string // 数据库用户名
	Password     string // 数据库密码
	MaxIdleConns int    `json:",default=10"` // 空闲中的最大连接数
	MaxOpenConns int    `json:",default=10"` // 打开到数据库的最大连接数
	LogMode      string `json:",default=dev,options=dev|test|prod|silent"`
	//LogZap        bool   // 是否通过zap写入日志文件
	SlowThreshold int64 `json:",default=1000"`
}

func (*Mysql) Dsn

func (m *Mysql) Dsn() string

func (*Mysql) GetColorful

func (m *Mysql) GetColorful() bool

func (*Mysql) GetGormLogMode

func (m *Mysql) GetGormLogMode() logger.LogLevel

func (*Mysql) GetSlowThreshold

func (m *Mysql) GetSlowThreshold() time.Duration

Jump to

Keyboard shortcuts

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