hotime/tools/db/auto.go

19 lines
488 B
Go
Raw Permalink Normal View History

2019-11-10 08:42:49 +00:00
package db
import (
2020-04-29 15:02:09 +00:00
"code.hoteas.com/golang/hotime"
"code.hoteas.com/golang/hotime/tools/mysql"
"code.hoteas.com/golang/hotime/tools/sqlite"
2019-11-10 08:42:49 +00:00
"strings"
)
func SetDB(appIns *hotime.Application) {
2019-11-10 08:49:05 +00:00
if appIns.Config.GetString("dbType") == "sqlite" || strings.Index(appIns.Config.GetString("dbName"), ".db") == len(appIns.Config.GetString("dbName"))-3 {
2019-11-10 08:51:27 +00:00
appIns.Config["dbType"] = "sqlite"
2019-11-10 08:42:49 +00:00
sqlite.SetDB(appIns)
} else {
2019-11-10 08:51:27 +00:00
appIns.Config["dbType"] = "mysql"
2019-11-10 08:42:49 +00:00
mysql.SetDB(appIns)
}
}