Nie możesz wybrać więcej, niż 25 tematów
Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
|
|
|
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(Category))
|
|
|
|
|
|
|
|
orm.RunSyncdb("default", false, true)
|
|
|
|
}
|