liuxiaolong
2020-10-10 bf4ca3fdb8c0f0c1f99a4a871ad39436cefc6ab6
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)
}