25개 이상의 토픽을 선택하실 수 없습니다.
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
527 B
18 lines
527 B
package models
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/beego/beego/v2/client/orm"
|
|
"github.com/beego/beego/v2/server/web"
|
|
_ "github.com/go-sql-driver/mysql"
|
|
)
|
|
|
|
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(Note), new(NoteColl), new(Category), new(Like), new(Comment))
|
|
|
|
orm.RunSyncdb("default", false, true)
|
|
}
|
|
|