Du kan inte välja fler än 25 ämnen
Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
24 rader
477 B
24 rader
477 B
6 år sedan
|
package models
|
||
|
|
||
|
import (
|
||
|
"github.com/Unknwon/com"
|
||
|
"os"
|
||
|
"path"
|
||
|
"github.com/astaxie/beego/orm"
|
||
|
_ "github.com/mattn/go-sqlite3"
|
||
|
)
|
||
|
|
||
|
const(
|
||
|
_DB_NAME = "data/beeblog.db"
|
||
|
_SQLITE3_DRIVER = "sqlite3"
|
||
|
)
|
||
|
|
||
|
func RegistDB() {
|
||
|
if !com.IsExist(_DB_NAME){
|
||
|
os.MkdirAll(path.Dir(_DB_NAME),os.ModePerm)
|
||
|
os.Create(_DB_NAME)
|
||
|
}
|
||
|
orm.RegisterModel(new(Category),new(Topic))
|
||
|
orm.RegisterDriver(_SQLITE3_DRIVER,orm.DRSqlite)
|
||
|
orm.RegisterDataBase("default",_SQLITE3_DRIVER,_DB_NAME,10)
|
||
|
}
|