forked from golang/hotime
19 lines
488 B
Go
19 lines
488 B
Go
|
package db
|
||
|
|
||
|
import (
|
||
|
"code.hoteas.com/golang/hotime"
|
||
|
"code.hoteas.com/golang/hotime/tools/mysql"
|
||
|
"code.hoteas.com/golang/hotime/tools/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)
|
||
|
}
|
||
|
}
|