package dbUtil

import (
	"fmt"
	"log"

	_ "github.com/go-sql-driver/mysql"
	"github.com/go-xorm/xorm"
)

var SqlEngine *xorm.Engine

func init() {
	var err error

	// ip := beego.AppConfig.String("sqlIp")
	// port := beego.AppConfig.String("sqlPort")
	// user := beego.AppConfig.String("sqlUser")
	// pwd := beego.AppConfig.String("sqlPwd")
	// dbname := beego.AppConfig.String("sqlName")
	// fmt.Println("ip", ip)
	// Engine, err = xorm.NewEngine("mysql", user+":"+pwd+"@tcp("+ip+":+"+port+")/"+dbname+"?charset=utf8")

	/* 	118.193.32.118
	game，1K91NDp%Y */

	Engine, err = xorm.NewEngine("mysql", "game:1K91NDp%Y@tcp(118.193.32.118:3306)/game?charset=utf8")
	err = Engine.Ping()

	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("==========Conn  Sqldb  SUCC==========")

}

//创建事务
func NewSession() *xorm.Session {
	return Engine.NewSession()
}
