Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- read -r -p "Type MySQL user (root): " USER
- if [ -z "$USER" ]; then
- USER=root
- fi
- read -r -p "Type MySQL $USER password: " PASS
- read -r -p "Type MySQL database name: " DBNAME
- read -r -p "Type MySQL database table: " DBTABLE
- INPUT=ietf-language-tags.csv
- [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
- # All columns from CSV must be defined, otherwise it concate all other to the last column
- while IFS="," read lang langType territory revGenDate defs dftLang file
- do
- echo "USE $DBNAME; INSERT INTO $DBTABLE (nameNative, nameEnglish, ietfCode, langType, territory) VALUES ('', '', '$lang', '$langType', '$territory');"
- done < $INPUT | mysql -u $USER -p$PASS;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement