码农笔录博客源码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
476 B

пре 6 година
package models
import (
пре 4 година
"fmt"
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/server/web"
пре 6 година
_ "github.com/go-sql-driver/mysql"
пре 6 година
)
пре 6 година
func RegistDB() {
dbUrl, _ := web.AppConfig.String("dburl")
пре 4 година
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))
пре 4 година
orm.RunSyncdb("default", false, true)
пре 6 година
}