Recently found some interesting gems that allow you to search postal codes via Geonames web service. In my case, I need more than just the country names, city names and region names. I need more relevant information like the currency code.

Ruby Geonames

Run the following if you haven't already:

sudo gem install elecnix-ruby-geonames

Seems like a complex solution to a very simple problem. The most simple solution to load geonames data into a new database separate from your application. When you're running backups, you really don't need to backup data that hardly every changes so I think it's a good idea to have a separate database.

Espen shares how to import countries, regions and cities in no more than 2 minutes

In my case it took me 4 minutes to load the data due to a minor issue regarding syntax.

LOAD DATA INFILE should be LOAD DATA LOCAL INFILE

6 megabytes of data migrated (2.5558s). Cool.

The data loaded does not have the full list of cities. But if you need the currency code (ISO 4217) of a country for instance that 2-second solution is definitely for you.

comments powered byDisqus

Hello! I am Kat. I've been a developer for several years. When I'm not sitting down, reading and working for long hours, I am traveling to some place of interest.
If you want to reach out, you can send me an email or add me up on Google Plus.