码农笔录博客源码
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

19 行
476 B

6 年前
package models
import (
"fmt"
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/server/web"
_ "github.com/go-sql-driver/mysql"
6 年前
)
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)
}