blob: 90ce6bc8a4ed0e807811bf74678e97bb3d8ce3ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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]}
|