forked from Qihoo360/wayne
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyncdb.go
More file actions
34 lines (28 loc) · 737 Bytes
/
syncdb.go
File metadata and controls
34 lines (28 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"fmt"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm"
_ "github.com/Qihoo360/wayne/src/backend/plugins"
)
func init() {
err := beego.LoadAppConfig("ini", "src/backend/conf/app.conf")
if err != nil {
panic(err)
}
}
func main() {
err := orm.RegisterDriver("mysql", orm.DRMySQL)
if err != nil {
panic(err)
}
dbURL := fmt.Sprintf("%s:%s@%s/%s?charset=utf8&", beego.AppConfig.String("DBUser"),
beego.AppConfig.String("DBPasswd"), beego.AppConfig.String("DBTns"), beego.AppConfig.String("DBName"))
// set timezone , same as db timezone
dbURL += beego.AppConfig.String("DBLoc")
err = orm.RegisterDataBase("default", "mysql", dbURL)
if err != nil {
panic(err)
}
orm.RunCommand()
}