码农笔录博客源码
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
527 B

6 years ago
package models
import (
4 years ago
"fmt"
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/server/web"
6 years ago
_ "github.com/go-sql-driver/mysql"
6 years ago
)
func RegistDB() {
dbUrl, _ := web.AppConfig.String("dburl")
4 years ago
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(Note), new(NoteColl), new(Category), new(Like), new(Comment))
4 years ago
orm.RunSyncdb("default", false, true)
}