Files
x_admin/server/config/db.go
2025-07-28 20:14:46 +08:00

26 lines
1.4 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package config
type dbConfig struct {
Type string `mapstructure:"TYPE"` // 数据库类型:MySQL, PostgreSQL, GaussDB, SQLite, SQLServer, TiDB
Dsn string `mapstructure:"DSN"` // 数据库
MaxOpenConns int `mapstructure:"MAX_OPEN_CONNS"` // 数据库连接池最大值
MaxIdleConns int `mapstructure:"MAX_IDLE_CONNS"` // 数据库空闲连接池最大值
ConnMaxLifetimeSeconds int `mapstructure:"CONN_MAX_LIFETIME_SECONDS"` // 连接可复用的最大时间(秒默认28800秒)
TablePrefix string `mapstructure:"TABLE_PREFIX"` // 数据库表前缀
SlowThreshold int `mapstructure:"SLOW_THRESHOLD"` // 数据库慢查询阈值(秒默认1秒)
LogLevel string `mapstructure:"LOG_LEVEL"` // 数据库日志级别
DefaultStringSize uint `mapstructure:"DEFAULT_STRING_SIZE"` // 数据库string类型字段的默认长度:256
}
var DBConfig = dbConfig{
Type: "MySQL",
Dsn: "", //root:123456@tcp(127.0.0.1:3306)/x_admin?charset=utf8mb4&parseTime=True&loc=Local
MaxOpenConns: 100,
MaxIdleConns: 50,
ConnMaxLifetimeSeconds: 6,
TablePrefix: "x_",
SlowThreshold: 1,
LogLevel: "info",
DefaultStringSize: 256,
}