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

6 years ago
package models
import (
3 years ago
"fmt"
"github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/config"
6 years ago
_ "github.com/go-sql-driver/mysql"
6 years ago
)
func RegistDB() {
3 years ago
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))
3 years ago
//orm.RunSyncdb("default", false, true)
}