package main

import (
	_ "github.com/mattn/go-sqlite3"
	"github.com/go-xorm/xorm"
	"github.com/go-xorm/core"
	"fmt"
)

var db *xorm.Engine

func DBinit() *xorm.Engine{
	SiteConf := initConfig()
	db, err := xorm.NewEngine("sqlite3", SiteConf.DBFile)
	if err != nil {
		fmt.Println(err)
	}

	db.SetMapper(core.SameMapper{})
	db.ShowSQL(true)
	db.Logger().SetLevel(core.LOG_DEBUG)
	return db
}