Skip to content

Commit bd07833

Browse files
authored
Merge pull request #30 from sunsingerus/master
airline.ontime table structure
2 parents 7e735f9 + ee3d1ff commit bd07833

File tree

1 file changed

+135
-22
lines changed

1 file changed

+135
-22
lines changed

README.md

+135-22
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1+
#
2+
3+
https://github.com/noplay/python-mysql-replication
4+
pip install mysql-replication
5+
6+
7+
https://github.com/mymarilyn/clickhouse-driver
8+
pip install clickhouse-driver
9+
10+
111
# clickhouse-mysql-data-reader
212
utility to read mysql data
313

414

5-
pip install mysql-replication
6-
715
you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation
816

917
CREATE USER 'reader'@'localhost' IDENTIFIED BY 'qwerty';
@@ -563,38 +571,31 @@ CREATE TABLE long_varbinary_datatypes(
563571
) ENGINE = Memory
564572
;
565573

566-
MySQL section
567574

568-
mysqlimport --ignore-lines=1 \
569-
--fields-terminated-by=, \
570-
--fields-enclosed-by=\" \
571-
--local -u root \
572-
-p Database \
573-
TableName.csv
575+
airline ontime test case
574576

577+
Import Data
575578

576579
ls|sort|head -n 100
580+
577581
i=1
578582
for file in $(ls *.csv|sort|head -n 100); do
579583
echo "$i. Copy $file"
580-
cp -f $file ontime
584+
cp -f $file ontime.csv
581585
echo "$i. Import $file"
582-
mysqlimport --ignore-lines=1 --fields-terminated-by=, --fields-enclosed-by=\" --local -u root airline ontime
583-
rm -f ontime
586+
mysqlimport \
587+
--ignore-lines=1 \
588+
--fields-terminated-by=, \
589+
--fields-enclosed-by=\" \
590+
--local \
591+
-u root \
592+
airline ontime.csv
593+
rm -f ontime.csv
584594
i=$((i+1))
585595
done
586596

587-
588-
589-
load data local infile 'file.csv' into table table
590-
fields terminated by ','
591-
enclosed by '"'
592-
lines terminated by '\n'
593-
(column1, column2, column3,...)
594-
595-
597+
MySQL
596598
CREATE DATABASE IF NOT EXISTS `airline`;
597-
598599
CREATE TABLE IF NOT EXISTS `airline`.`ontime` (
599600
`Year` SMALLINT UNSIGNED, -- UInt16,
600601
`Quarter` TINYINT UNSIGNED, -- UInt8,
@@ -707,3 +708,115 @@ CREATE TABLE IF NOT EXISTS `airline`.`ontime` (
707708
`Div5TailNum` LONGTEXT -- String
708709
);
709710

711+
ClickHouse
712+
CREATE TABLE IF NOT EXISTS `airline`.`ontime` (
713+
`Year` UInt16,
714+
`Quarter` UInt8,
715+
`Month` UInt8,
716+
`DayofMonth` UInt8,
717+
`DayOfWeek` UInt8,
718+
`FlightDate` Date,
719+
`UniqueCarrier` String,
720+
`AirlineID` UInt32,
721+
`Carrier` String,
722+
`TailNum` String,
723+
`FlightNum` String,
724+
`OriginAirportID` UInt32,
725+
`OriginAirportSeqID` UInt32,
726+
`OriginCityMarketID` UInt32,
727+
`Origin` String,
728+
`OriginCityName` String,
729+
`OriginState` String,
730+
`OriginStateFips` String,
731+
`OriginStateName` String,
732+
`OriginWac` UInt32,
733+
`DestAirportID` UInt32,
734+
`DestAirportSeqID` UInt32,
735+
`DestCityMarketID` UInt32,
736+
`Dest` String,
737+
`DestCityName` String,
738+
`DestState` String,
739+
`DestStateFips` String,
740+
`DestStateName` String,
741+
`DestWac` UInt32,
742+
`CRSDepTime` UInt32,
743+
`DepTime` UInt32,
744+
`DepDelay` Float32,
745+
`DepDelayMinutes` Float32,
746+
`DepDel15` Float32,
747+
`DepartureDelayGroups` Int32,
748+
`DepTimeBlk` String,
749+
`TaxiOut` Float32,
750+
`WheelsOff` UInt32,
751+
`WheelsOn` UInt32,
752+
`TaxiIn` Float32,
753+
`CRSArrTime` UInt32,
754+
`ArrTime` UInt32,
755+
`ArrDelay` Float32,
756+
`ArrDelayMinutes` Float32,
757+
`ArrDel15` Float32,
758+
`ArrivalDelayGroups` Int32,
759+
`ArrTimeBlk` String,
760+
`Cancelled` Float32,
761+
`CancellationCode` String,
762+
`Diverted` Float32,
763+
`CRSElapsedTime` Float32,
764+
`ActualElapsedTime` Float32,
765+
`AirTime` Float32,
766+
`Flights` Float32,
767+
`Distance` Float32,
768+
`DistanceGroup` Float32,
769+
`CarrierDelay` Float32,
770+
`WeatherDelay` Float32,
771+
`NASDelay` Float32,
772+
`SecurityDelay` Float32,
773+
`LateAircraftDelay` Float32,
774+
`FirstDepTime` String,
775+
`TotalAddGTime` String,
776+
`LongestAddGTime` String,
777+
`DivAirportLandings` String,
778+
`DivReachedDest` String,
779+
`DivActualElapsedTime` String,
780+
`DivArrDelay` String,
781+
`DivDistance` String,
782+
`Div1Airport` String,
783+
`Div1AirportID` UInt32,
784+
`Div1AirportSeqID` UInt32,
785+
`Div1WheelsOn` String,
786+
`Div1TotalGTime` String,
787+
`Div1LongestGTime` String,
788+
`Div1WheelsOff` String,
789+
`Div1TailNum` String,
790+
`Div2Airport` String,
791+
`Div2AirportID` UInt32,
792+
`Div2AirportSeqID` UInt32,
793+
`Div2WheelsOn` String,
794+
`Div2TotalGTime` String,
795+
`Div2LongestGTime` String,
796+
`Div2WheelsOff` String,
797+
`Div2TailNum` String,
798+
`Div3Airport` String,
799+
`Div3AirportID` UInt32,
800+
`Div3AirportSeqID` UInt32,
801+
`Div3WheelsOn` String,
802+
`Div3TotalGTime` String,
803+
`Div3LongestGTime` String,
804+
`Div3WheelsOff` String,
805+
`Div3TailNum` String,
806+
`Div4Airport` String,
807+
`Div4AirportID` UInt32,
808+
`Div4AirportSeqID` UInt32,
809+
`Div4WheelsOn` String,
810+
`Div4TotalGTime` String,
811+
`Div4LongestGTime` String,
812+
`Div4WheelsOff` String,
813+
`Div4TailNum` String,
814+
`Div5Airport` String,
815+
`Div5AirportID` UInt32,
816+
`Div5AirportSeqID` UInt32,
817+
`Div5WheelsOn` String,
818+
`Div5TotalGTime` String,
819+
`Div5LongestGTime` String,
820+
`Div5WheelsOff` String,
821+
`Div5TailNum` String
822+
) ENGINE = MergeTree(FlightDate, (FlightDate, Year, Month, DepDel15), 8192)

0 commit comments

Comments
 (0)