// NewSQLRunner opens a connections using the given DSN
NewSQLRunner opens a connections using the given DSN
// NewSQLRunner opens a connections using the given DSN
func NewSQLRunner(cfg *Config, errs ...error) (SQLRunner, func(), error) {
	var db *sql.DB
	var close func()
	if len(errs) > 0 && errs[0] != nil {
		return nil, close, errs[0]
	}
	db, err := sql.Open("mysql", cfg.GetMysqlDSN())
	if err != nil {
		return nil, close, err
	}
	close = func() {
		if cErr := db.Close(); cErr != nil {
			log.Error(cErr, "failed closing the database connection")
		}
	}
	return &sqlRunner{db: db}, close, nil
}
func NewSQLRunner ( cfg * Config , errs ... error ) ( SQLRunner , func ( ) , error ) { var db * sql . DB var close func ( ) if len ( errs ) > 0 && errs [ 0 ] != nil { return nil , close , errs [ 0 ] } db , err := sql . Open ( " " , cfg . GetMysqlDSN ( ) ) if err != nil { return nil , close , err } close = func ( ) { if cErr := db . Close ( ) ; cErr != nil { log . Error ( cErr , " " ) } } return & sqlRunner { db : db } , close , nil }
NewSQLRunner opens a connections using the given DSN
NewSQLRunner opens a connections using the given DSN
// make this factory accept a functions that tries to generate a config // close connection function