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