Skip to content

Instantly share code, notes, and snippets.

@umardx
Created October 12, 2020 13:36
Show Gist options
  • Save umardx/ed00616c423d88844842ea2314bf7ad9 to your computer and use it in GitHub Desktop.
Save umardx/ed00616c423d88844842ea2314bf7ad9 to your computer and use it in GitHub Desktop.
#/bin/bash
echo "${DEPLOYMENT_TARGET_CSV}" | while IFS=, read -r serviceName serviceRole serviceCountry others;do
if [ -z "$serviceName" ] || [ -z "$serviceRole" ] || [ -z "$serviceCountry" ];then
continue
fi
QUERY="INSERT IGNORE INTO newton.deployment_target (service_name,role,country_abbrv) VALUES ('${serviceName}','${serviceRole}','${serviceCountry}');"
echo ">${QUERY}"
mysql --user="$mysql_user" --password="$mysql_password" --host="$mysql_host" -ss --execute="${QUERY}" > /dev/null 2>&1
if [[ "$?" -ne 0 ]]; then
>&2 echo "[MYSQL ERROR] Failed connecting to MySQL host. Could be connection or user password problem. Exit code $exit_code"
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment