Advertisement
Guest User

Untitled

a guest
Apr 11th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. read -r -p "Type MySQL user (root): " USER
  4. if [ -z "$USER" ]; then
  5. USER=root
  6. fi
  7.  
  8. read -r -p "Type MySQL $USER password: " PASS
  9. read -r -p "Type MySQL database name: " DBNAME
  10. read -r -p "Type MySQL database table: " DBTABLE
  11.  
  12.  
  13. INPUT=ietf-language-tags.csv
  14. [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
  15.  
  16. # All columns from CSV must be defined, otherwise it concate all other to the last column
  17. while IFS="," read lang langType territory revGenDate defs dftLang file
  18. do
  19. echo "USE $DBNAME; INSERT INTO $DBTABLE (nameNative, nameEnglish, ietfCode, langType, territory) VALUES ('', '', '$lang', '$langType', '$territory');"
  20. done < $INPUT | mysql -u $USER -p$PASS;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement