load_torrentsjson.sh
1 #!/bin/bash 2 3 set -Eeuxo pipefail 4 5 # Run this script by running: docker exec -it aa-data-import--web /scripts/load_openlib.sh 6 # Feel free to comment out steps in order to retry failed parts of this script, when necessary. 7 # Load scripts are idempotent, and can be rerun without losing too much work. 8 9 cd /temp-dir/torrents_json 10 11 pv torrents.json | mariadb -h aa-data-import--mariadb -u root -ppassword allthethings --local-infile=1 --show-warnings -vv -e "DROP TABLE IF EXISTS torrents_json; CREATE TABLE torrents_json (json JSON NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin; LOAD DATA LOCAL INFILE '/dev/stdin' INTO TABLE torrents_json FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '';"