package models

import (
	"github.com/astaxie/beego"
	"github.com/go-xorm/xorm"
	_ "github.com/mattn/go-sqlite3"
)

var (
	Dao *xorm.Engine
)

func init() {
	Dao = NewDAO()
}

// NewDAO 初始化数据库连接
func NewDAO() *xorm.Engine {
	dbType := "sqlite3"

	dao, err := xorm.NewEngine(dbType, beego.AppConfig.String("dbfile"))
	// dao.ShowSQL()

	if err != nil {
		panic(err)
		return nil
	}

	Dao = dao
	return dao
}
