func CreateMySQLDBSession(kubectlConfig kubernetes.Interface, namespace string, cfg *config.MySQLConfig, persistPool *config.ConnectionPool) (sqlbuilder.Database, string, error) {

	if cfg.TableName == "" {
		return nil, "", errors.InternalError("tableName is empty")
	}

	userNameByte, err := util.GetSecrets(kubectlConfig, namespace, cfg.UsernameSecret.Name, cfg.UsernameSecret.Key)
	if err != nil {
		return nil, "", err
	}
	passwordByte, err := util.GetSecrets(kubectlConfig, namespace, cfg.PasswordSecret.Name, cfg.PasswordSecret.Key)
	if err != nil {
		return nil, "", err
	}

	session, err := mysql.Open(mysql.ConnectionURL{
		User:     string(userNameByte),
		Password: string(passwordByte),
		Host:     cfg.Host + ":" + cfg.Port,
		Database: cfg.Database,
	})
	if err != nil {
		return nil, "", err
	}

	if persistPool != nil {
		session.SetMaxOpenConns(persistPool.MaxOpenConns)
		session.SetMaxIdleConns(persistPool.MaxIdleConns)
	}
	// this is needed to make MySQL run in a Golang-compatible UTF-8 character set.
	_, err = session.Exec("SET NAMES 'utf8mb4'")
	if err != nil {
		return nil, "", err
	}
	_, err = session.Exec("SET CHARACTER SET utf8mb4")
	if err != nil {
		return nil, "", err
	}
	return session, cfg.TableName, nil
}
// CreateMySQLDBSession creates Mysql DB session
CreateMySQLDBSession creates Mysql DB session
// CreateMySQLDBSession creates Mysql DB session
func CreateMySQLDBSession(kubectlConfig kubernetes.Interface, namespace string, cfg *config.MySQLConfig, persistPool *config.ConnectionPool) (sqlbuilder.Database, string, error) {
	if cfg.TableName == "" {
		return nil, "", errors.InternalError("tableName is empty")
	}
	userNameByte, err := util.GetSecrets(kubectlConfig, namespace, cfg.UsernameSecret.Name, cfg.UsernameSecret.Key)
	if err != nil {
		return nil, "", err
	}
	passwordByte, err := util.GetSecrets(kubectlConfig, namespace, cfg.PasswordSecret.Name, cfg.PasswordSecret.Key)
	if err != nil {
		return nil, "", err
	}
	session, err := mysql.Open(mysql.ConnectionURL{
		User:     string(userNameByte),
		Password: string(passwordByte),
		Host:     cfg.Host + ":" + cfg.Port,
		Database: cfg.Database,
	})
	if err != nil {
		return nil, "", err
	}
	if persistPool != nil {
		session.SetMaxOpenConns(persistPool.MaxOpenConns)
		session.SetMaxIdleConns(persistPool.MaxIdleConns)
	}
	_, err = session.Exec("SET NAMES 'utf8mb4'")
	if err != nil {
		return nil, "", err
	}
	_, err = session.Exec("SET CHARACTER SET utf8mb4")
	if err != nil {
		return nil, "", err
	}
	return session, cfg.TableName, nil
}
func CreateMySQLDBSession ( kubectlConfig kubernetes . Interface , namespace string , cfg * config . MySQLConfig , persistPool * config . ConnectionPool ) ( sqlbuilder . Database , string , error ) { if cfg . TableName == " " { return nil , " " , errors . InternalError ( " " ) } userNameByte , err := util . GetSecrets ( kubectlConfig , namespace , cfg . UsernameSecret . Name , cfg . UsernameSecret . Key ) if err != nil { return nil , " " , err } passwordByte , err := util . GetSecrets ( kubectlConfig , namespace , cfg . PasswordSecret . Name , cfg . PasswordSecret . Key ) if err != nil { return nil , " " , err } session , err := mysql . Open ( mysql . ConnectionURL { User : string ( userNameByte ) , Password : string ( passwordByte ) , Host : cfg . Host + " " + cfg . Port , Database : cfg . Database , } ) if err != nil { return nil , " " , err } if persistPool != nil { session . SetMaxOpenConns ( persistPool . MaxOpenConns ) session . SetMaxIdleConns ( persistPool . MaxIdleConns ) } _ , err = session . Exec ( " " ) if err != nil { return nil , " " , err } _ , err = session . Exec ( " " ) if err != nil { return nil , " " , err } return session , cfg . TableName , nil }
CreateMySQLDBSession creates Mysql DB session
CreateMySQLDBSession creates Mysql DB session
// this is needed to make MySQL run in a Golang-compatible UTF-8 character set.