hotime/tools/db/auto.go

19 lines
488 B
Go
Raw Normal View History

2019-11-10 08:42:49 +00:00
package db
import (
"code.hoteas.com/hoteas/hotime"
"code.hoteas.com/hoteas/hotime/tools/mysql"
"code.hoteas.com/hoteas/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)
}
}