diff options
author | emkael <emkael@tlen.pl> | 2017-09-08 01:28:21 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2017-09-08 01:28:21 +0200 |
commit | 8f795b1d445441daab5ffb75060a6dbf8ed0934a (patch) | |
tree | 15e55a2a7e03867ac0cccfb8303674d478510503 /bin/rankings-csv-import.sh | |
parent | 655a9847513332e8e119f37f7ed95f4ab002b1a1 (diff) |
Renaming scripts so that their names make sense
Diffstat (limited to 'bin/rankings-csv-import.sh')
-rwxr-xr-x | bin/rankings-csv-import.sh | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bin/rankings-csv-import.sh b/bin/rankings-csv-import.sh new file mode 100755 index 0000000..90ce6bc --- /dev/null +++ b/bin/rankings-csv-import.sh @@ -0,0 +1,16 @@ +#!/bin/bash +DBCONFIG=($(jq -r '.[]' config/import-db.json)) +mysql -h ${DBCONFIG[2]} -P ${DBCONFIG[3]} -u ${DBCONFIG[0]} --password=${DBCONFIG[1]} -e "SET foreign_key_checks = 0; +DELETE FROM temp_rankings; +LOAD DATA LOCAL INFILE '$1' +REPLACE +INTO TABLE temp_rankings +FIELDS TERMINATED BY ','; +INSERT INTO rankings ( + SELECT pid, \`date\`, place, score, region, flags, rank, club + FROM temp_rankings + JOIN players + ON players.id = temp_rankings.pid +); +SET foreign_key_checks = 1 +" ${DBCONFIG[4]} |