|
|
@ -27,7 +27,7 @@ func init() {
|
|
|
|
fmt.Println(err)
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//注册SqlMap配置,可选功能,如应用中无需使用SqlMap,可无需初始化
|
|
|
|
//注册SqlMap配置,可选功能,如应用中无需使用SqlMap,可无需初始化
|
|
|
|
err =Engine.RegisterSqlMap(xorm.Xml("./Sql", ".xml"))
|
|
|
|
err = Engine.RegisterSqlMap(xorm.Xml("./Sql", ".xml"))
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
fmt.Println(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -36,7 +36,8 @@ func init() {
|
|
|
|
Engine.SetMaxOpenConns(100) //设置打开数据库的最大连接数,包含正在使用的连接和连接池的连接。
|
|
|
|
Engine.SetMaxOpenConns(100) //设置打开数据库的最大连接数,包含正在使用的连接和连接池的连接。
|
|
|
|
Engine.SetMaxIdleConns(10) //设置连接池中的保持连接的最大连接数。
|
|
|
|
Engine.SetMaxIdleConns(10) //设置连接池中的保持连接的最大连接数。
|
|
|
|
Engine.SetConnMaxLifetime(time.Second * 30)
|
|
|
|
Engine.SetConnMaxLifetime(time.Second * 30)
|
|
|
|
|
|
|
|
//打开xorm的sql日志
|
|
|
|
|
|
|
|
Engine.ShowSQL(true)
|
|
|
|
//调用第一次
|
|
|
|
//调用第一次
|
|
|
|
Engine.Ping()
|
|
|
|
Engine.Ping()
|
|
|
|
|
|
|
|
|
|
|
@ -60,7 +61,7 @@ func init() {
|
|
|
|
Engine.SetTableMapper(core.SnakeMapper{})
|
|
|
|
Engine.SetTableMapper(core.SnakeMapper{})
|
|
|
|
|
|
|
|
|
|
|
|
//显示+记录SQL日志
|
|
|
|
//显示+记录SQL日志
|
|
|
|
f, _ := os.Create(ConfigUtil.DistributeRemotePath+"sql.log")
|
|
|
|
f, _ := os.Create(ConfigUtil.DistributeRemotePath + "sql.log")
|
|
|
|
Engine.SetLogger(log.NewSimpleLogger(f))
|
|
|
|
Engine.SetLogger(log.NewSimpleLogger(f))
|
|
|
|
|
|
|
|
|
|
|
|
Engine.ShowSQL(true) // 则会在控制台打印出生成的SQL语句
|
|
|
|
Engine.ShowSQL(true) // 则会在控制台打印出生成的SQL语句
|
|
|
|