Last active
December 17, 2015 22:09
-
-
Save ramannanda9/5680115 to your computer and use it in GitHub Desktop.
MySql GeoPlanet data and data loading script
This file contains 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 TABLE `places` ( | |
`woeid` int(15) NOT NULL, | |
`iso` varchar(6) NOT NULL, | |
`name` text NOT NULL, | |
`language` varchar(6) NOT NULL, | |
`type` varchar(30) NOT NULL, | |
`parent` int(15) NOT NULL, | |
PRIMARY KEY (`woeid`) | |
) ENGINE=INNODB DEFAULT CHARSET=utf8; | |
--to load the data into DB use concurrent load utility | |
LOAD DATA concurrent infile "C:\\Users\\bleh\\Downloads\\geoplanet_places_7.9.0.tsv" into table | |
places | |
fields terminated by '\t' | |
lines terminated by '\n' | |
ignore 1 lines | |
--for locating places by names / aliases | |
CREATE TABLE `aliases` ( | |
`woeid` int(15) NOT NULL, | |
`name` text NOT NULL, | |
`name-type` varchar(10) NOT NULL, | |
`language` varchar(10) DEFAULT NULL, | |
KEY `woeid` (`woeid`) | |
) ENGINE=INNODB DEFAULT CHARSET=utf8; | |
--to load data | |
LOAD DATA concurrent infile "C:\\Users\\bleh\\Downloads\\aliases.tsv" into table | |
places | |
fields terminated by '\t' | |
lines terminated by '\n' | |
ignore 1 lines | |
--for locating places near the place | |
CREATE TABLE adjacencies | |
( | |
`place_woe_id` int(15) NOT NULL, | |
`place_iso` varchar(6) NOT NULL, | |
`neighbour_woe_id` int(15) NOT NULL, | |
`neighbour_iso` varchar(6) NOT NULL, | |
PRIMARY KEY (`place_woe_id`, `neighbour_woe_id`) | |
)ENGINE=INNODB DEFAULT CHARSET=utf8; | |
LOAD DATA concurrent infile "C:\\Users\\bleh\\Downloads\\adjacencies.tsv" into table | |
places | |
fields terminated by '\t' | |
lines terminated by '\n' | |
ignore 1 lines |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment