您最多选择25个主题
主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
18 行
476 B
18 行
476 B
package models
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/beego/beego/v2/client/orm"
|
|
"github.com/beego/beego/v2/server/web"
|
|
_ "github.com/go-sql-driver/mysql"
|
|
)
|
|
|
|
func RegistDB() {
|
|
dbUrl, _ := web.AppConfig.String("dburl")
|
|
fmt.Println(dbUrl)
|
|
orm.RegisterDriver("mysql", orm.DRMySQL)
|
|
orm.RegisterDataBase("default", "mysql", "root:"+dbUrl+"/beeblog?charset=utf8&loc=Local")
|
|
orm.RegisterModel(new(User), new(Blog), new(NLabel), new(Category))
|
|
|
|
orm.RunSyncdb("default", false, true)
|
|
}
|
|
|