liuxiaolong
2020-10-10 0537a0d260765043dda3ff1a73f14cfa831d1b43
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package models
 
import (
    "car-service/extend/util"
    "github.com/astaxie/beego"
    "github.com/astaxie/beego/orm"
    _ "github.com/mattn/go-sqlite3"
)
 
func InitDb() {
    dbUrl := beego.AppConfig.String("dbUrl")
    rootPath := util.GetAppRootPath()
    dbPath := rootPath +"/"+ dbUrl
    orm.RegisterDriver("sqlite", orm.DRSqlite)
    _ = orm.RegisterDataBase("default", "sqlite3", dbPath)
    orm.RegisterModel(new(User), new(UserCar), new(SysUpgrade), new(UserClient), new(Restriction), new(Log))
    _ = orm.RunSyncdb("default", false, true)
}