iedc-go/dri/db/auto.go
2019-11-10 16:51:27 +08:00

19 lines
484 B
Go

package db
import (
"code.hoteas.com/hoteas/hotime"
"code.hoteas.com/hoteas/hotime/dri/mysql"
"code.hoteas.com/hoteas/hotime/dri/sqlite"
"strings"
)
func SetDB(appIns *hotime.Application) {
if appIns.Config.GetString("dbType") == "sqlite" || strings.Index(appIns.Config.GetString("dbName"), ".db") == len(appIns.Config.GetString("dbName"))-3 {
appIns.Config["dbType"] = "sqlite"
sqlite.SetDB(appIns)
} else {
appIns.Config["dbType"] = "mysql"
mysql.SetDB(appIns)
}
}