Created
August 13, 2018 10:29
-
-
Save JoolsF/59623d4bfcbe8de8951936c80a8316c6 to your computer and use it in GitHub Desktop.
db query shell script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| DB_USER="???" | |
| DB_PASS="???" | |
| DB_HOST="???" | |
| if [ ! "$DB_USER" ] || [ ! "$DB_PASS" ] || [ ! "$DB_HOST" ]; then | |
| echo "You need to set DB_USER, DB_PASS and DB_HOST environmental variables." | |
| exit 1 | |
| fi | |
| # escape new lines and backticks | |
| mysql -u${DB_USER} \ | |
| -p${DB_PASS} \ | |
| -h${DB_HOST} \ | |
| my_db_name -e "SELECT * \ | |
| FROM \`foo\`.\`bar\` fb"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment