Commit 92d723d6 by Daniel Lee

docker: remove downloaded temp files from opendata image

parent 9e0acdda
...@@ -12,7 +12,8 @@ RUN apt-get update && apt-get install -y wget && apt-get install unzip ...@@ -12,7 +12,8 @@ RUN apt-get update && apt-get install -y wget && apt-get install unzip
# Fetch NYC Data Set # Fetch NYC Data Set
RUN wget https://data.cityofnewyork.us/download/57g5-etyj/application%2Fzip -O /tmp/data.zip && \ RUN wget https://data.cityofnewyork.us/download/57g5-etyj/application%2Fzip -O /tmp/data.zip && \
unzip -j /tmp/data.zip 311_Service_Requests_from_2015.csv -d /var/lib/mysql-files unzip -j /tmp/data.zip 311_Service_Requests_from_2015.csv -d /var/lib/mysql-files && \
rm /tmp/data.zip
ADD import_csv.sql /docker-entrypoint-initdb.d/ ADD import_csv.sql /docker-entrypoint-initdb.d/
......
...@@ -56,23 +56,25 @@ CREATE TABLE IF NOT EXISTS `nyc_open_data` ( ...@@ -56,23 +56,25 @@ CREATE TABLE IF NOT EXISTS `nyc_open_data` (
Location varchar(255) Location varchar(255)
); );
LOAD DATA INFILE '/var/lib/mysql-files/311_Service_Requests_from_2015.csv' INTO TABLE nyc_open_data FIELDS OPTIONALLY ENCLOSED BY '"' TERMINATED BY ',' IGNORE 1 LINES; LOAD DATA INFILE '/var/lib/mysql-files/311_Service_Requests_from_2015.csv' INTO TABLE nyc_open_data FIELDS OPTIONALLY ENCLOSED BY '"' TERMINATED BY ',' IGNORE 1 LINES;
update nyc_open_data set CreatedDate = STR_TO_DATE(CreatedDate, '%m/%d/%Y %r') where CreatedDate <> ''; UPDATE nyc_open_data SET CreatedDate = STR_TO_DATE(CreatedDate, '%m/%d/%Y %r') WHERE CreatedDate <> '';
update nyc_open_data set ClosedDate = STR_TO_DATE(ClosedDate, '%m/%d/%Y %r') where ClosedDate <> ''; UPDATE nyc_open_data SET ClosedDate = STR_TO_DATE(ClosedDate, '%m/%d/%Y %r') WHERE ClosedDate <> '';
update nyc_open_data set DueDate = STR_TO_DATE(DueDate, '%m/%d/%Y %r') where DueDate <> ''; UPDATE nyc_open_data SET DueDate = STR_TO_DATE(DueDate, '%m/%d/%Y %r') WHERE DueDate <> '';
update nyc_open_data set ResolutionActionUpdatedDate = STR_TO_DATE(ResolutionActionUpdatedDate, '%m/%d/%Y %r') where ResolutionActionUpdatedDate <> ''; UPDATE nyc_open_data SET ResolutionActionUpdatedDate = STR_TO_DATE(ResolutionActionUpdatedDate, '%m/%d/%Y %r') WHERE ResolutionActionUpdatedDate <> '';
update nyc_open_data set CreatedDate=null where CreatedDate = ''; UPDATE nyc_open_data SET CreatedDate=null WHERE CreatedDate = '';
update nyc_open_data set ClosedDate=null where ClosedDate = ''; UPDATE nyc_open_data SET ClosedDate=null WHERE ClosedDate = '';
update nyc_open_data set DueDate=null where DueDate = ''; UPDATE nyc_open_data SET DueDate=null WHERE DueDate = '';
update nyc_open_data set ResolutionActionUpdatedDate=null where ResolutionActionUpdatedDate = ''; UPDATE nyc_open_data SET ResolutionActionUpdatedDate=null WHERE ResolutionActionUpdatedDate = '';
alter table nyc_open_data modify CreatedDate datetime null; ALTER TABLE nyc_open_data modify CreatedDate datetime NULL;
alter table nyc_open_data modify ClosedDate datetime null; ALTER TABLE nyc_open_data modify ClosedDate datetime NULL;
alter table nyc_open_data modify DueDate datetime null; ALTER TABLE nyc_open_data modify DueDate datetime NULL;
alter table nyc_open_data modify ResolutionActionUpdatedDate datetime null; ALTER TABLE nyc_open_data modify ResolutionActionUpdatedDate datetime NULL;
ALTER TABLE `nyc_open_data` ADD INDEX `IX_ComplaintType` (`ComplaintType`); ALTER TABLE `nyc_open_data` ADD INDEX `IX_ComplaintType` (`ComplaintType`);
ALTER TABLE `nyc_open_data` ADD INDEX `IX_CreatedDate` (`CreatedDate`); ALTER TABLE `nyc_open_data` ADD INDEX `IX_CreatedDate` (`CreatedDate`);
ALTER TABLE `nyc_open_data` ADD INDEX `IX_LocationType` (`LocationType`); ALTER TABLE `nyc_open_data` ADD INDEX `IX_LocationType` (`LocationType`);
ALTER TABLE `nyc_open_data` ADD INDEX `IX_AgencyName` (`AgencyName`); ALTER TABLE `nyc_open_data` ADD INDEX `IX_AgencyName` (`AgencyName`);
ALTER TABLE `nyc_open_data` ADD INDEX `IX_City` (`City`); ALTER TABLE `nyc_open_data` ADD INDEX `IX_City` (`City`);
SYSTEM rm /var/lib/mysql-files/311_Service_Requests_from_2015.csv
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment