summaryrefslogtreecommitdiff
path: root/bin/import-rankings.sh
blob: d73af6494423276d33e7d4a3448c09a838183051 (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
       FROM temp_rankings
       JOIN players
            ON players.id = temp_rankings.pid
);
SET foreign_key_checks = 1
" ${DBCONFIG[4]}