Forked from dgadiraju/01_nyse_create_table_quickstart.sql
Created
August 21, 2019 10:33
-
-
Save zz22394/a0b0f00af9aa0ef0b430effff8fed4c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DATABASE nyse; | |
CREATE USER 'nyse_user' IDENTIFIED BY 'itversity'; | |
GRANT ALL ON nyse.* TO nyse_user; | |
GRANT FILE ON *.* TO nyse_user; | |
GRANT SUPER ON *.* TO nyse_user; | |
FLUSH PRIVILEGES; | |
USE nyse; | |
CREATE TABLE `stock_eod` ( | |
`stockticker` varchar(10) NOT NULL DEFAULT '', | |
`tradedate` varchar(30) NOT NULL DEFAULT '', | |
`openprice` decimal(10,2) DEFAULT NULL, | |
`highprice` decimal(10,2) DEFAULT NULL, | |
`lowprice` decimal(10,2) DEFAULT NULL, | |
`closeprice` decimal(10,2) DEFAULT NULL, | |
`volume` bigint(20) DEFAULT NULL, | |
PRIMARY KEY (`stockticker`,`tradedate`) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We will be using /data as the reference directory | |
sudo mkdir -p /data | |
sudo su - root | |
cd /data | |
git clone https://github.com/dgadiraju/nyse_all.git | |
gunzip /data/nyse_all/nyse_data/* | |
for f in /data/nyse_all/nyse_data/*.txt | |
do | |
unlink stock_eod.txt | |
ln -s $f stock_eod.txt | |
mysqlimport \ | |
--host=127.0.0.1 \ | |
--user=nyse_user \ | |
--password=itversity \ | |
--fields-terminated-by=',' \ | |
--lines-terminated-by='\n' \ | |
--local \ | |
--lock-tables \ | |
--verbose \ | |
nyse stock_eod.txt | |
echo "Done: '"$f"' at $(date)" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment