//use goini read the configuration file and connect the mysql database
use goini read the configuration file and connect the mysql database
// use goini read the configuration file and connect the mysql database
func SetConfig(filename string) (*DbHandle, error) {
	fmt.Println(filename)
	conf := goini.SetConfig(filename)
	charset := conf.GetValue("database", "charset")
	username := conf.GetValue("database", "username")
	password := conf.GetValue("database", "password")
	hostname := conf.GetValue("database", "hostname")
	database := conf.GetValue("database", "database")
	port := conf.GetValue("database", "port")
	db, err := sql.Open("mysql", username+":"+password+"@tcp("+hostname+":"+port+")/"+database+"?charset="+charset)
	err = db.Ping()
	c := new(DbHandle)
	if err != nil {
		return c, err
	}
	c.Db = db
	return c, nil
}
func SetConfig ( filename string ) ( * DbHandle , error ) { fmt . Println ( filename ) conf := goini . SetConfig ( filename ) charset := conf . GetValue ( " " , " " ) username := conf . GetValue ( " " , " " ) password := conf . GetValue ( " " , " " ) hostname := conf . GetValue ( " " , " " ) database := conf . GetValue ( " " , " " ) port := conf . GetValue ( " " , " " ) db , err := sql . Open ( " " , username + " " + password + " " + hostname + " " + port + " " + database + " " + charset ) err = db . Ping ( ) c := new ( DbHandle ) if err != nil { return c , err } c . Db = db return c , nil }
use goini read the configuration file and connect the mysql database
use goini read the configuration file and connect the mysql database
//if connect error then return the error message