码农笔录博客源码
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

24 行
477 B

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)
}