mysql

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 9 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)

func MustConnect

func MustConnect(m Mysql) *gorm.DB

func MustConnectWithConfig

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

Types

type Mysql

type Mysql struct {
	Path          string // 服务器地址
	Port          int    `json:",default=3306"` // 端口
	Config        string `json:",optional"`     // default: charset=utf8mb4&parseTime=True&loc=Local 高级配置
	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"` // 是否开启Gorm全局日志
	SlowThreshold int64  `json:",default=1000"`
}

func (*Mysql) Dsn

func (m *Mysql) Dsn() string

func (*Mysql) GetColorful

func (m *Mysql) GetColorful() bool

func (*Mysql) GetConnConfig

func (m *Mysql) GetConnConfig() string

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