Browse Source

mysql 加打开日志打印模式

main
haima1004 5 years ago
parent
commit
e1c60ff06b
  1. 13
      QMPlusServer/config/config.go
  2. 5
      QMPlusServer/init/qmsql/initMysql.go
  3. 7
      QMPlusServer/static/config/config.json

13
QMPlusServer/config/config.go

@ -31,11 +31,14 @@ type CasbinConfig struct { //casbin配置
}
type MysqlAdmin struct { // mysql admin 数据库配置
Username string `json:"username"`
Password string `json:"password"`
Path string `json:"path"`
Dbname string `json:"dbname"`
Config string `json:"config"`
Username string `json:"username"`
Password string `json:"password"`
Path string `json:"path"`
Dbname string `json:"dbname"`
Config string `json:"config"`
MaxIdleConns int `json:"maxIdleConns"`
MaxOpenConns int `json:"maxOpenConns"`
LogMode bool `json:"maxOpenConns"`
}
type RedisAdmin struct { // Redis admin 数据库配置

5
QMPlusServer/init/qmsql/initMysql.go

@ -15,8 +15,9 @@ func InitMysql(admin config.MysqlAdmin) *gorm.DB {
log.Printf("DEFAULTDB数据库启动异常%S", err)
} else {
DEFAULTDB = db
DEFAULTDB.DB().SetMaxIdleConns(10)
DEFAULTDB.DB().SetMaxOpenConns(100)
DEFAULTDB.DB().SetMaxIdleConns(admin.MaxIdleConns)
DEFAULTDB.DB().SetMaxOpenConns(admin.MaxOpenConns)
DEFAULTDB.LogMode(admin.LogMode)
}
return DEFAULTDB
}

7
QMPlusServer/static/config/config.json

@ -7,10 +7,13 @@
},
"mysqladmin": {
"username": "root",
"password": "Aa@6447985",
"password": "123456",
"path": "127.0.0.1:3306",
"dbname": "qmPlus",
"config": "charset=utf8\u0026parseTime=True\u0026loc=Local"
"config": "charset=utf8\u0026parseTime=True\u0026loc=Local",
"maxIdleConns": 10,
"maxOpenConns": 100,
"logMode": true
},
"qiniu": {
"accessKey": "25j8dYBZ2wuiy0yhwShytjZDTX662b8xiFguwxzZ",

Loading…
Cancel
Save