Sometimes you just need file of cities and their lat/long locations. Thanks to MaxMind you can download an enormous CSV list of political entities. The city location csv file is about 22MB and can be used for creating or adding to any database.
From Max Mind:
The GeoLite databases are our free IP geolocation databases. They are updated on the first Tuesday of each month. These databases are offered in the same binary and csv formats as our subscription databases. Any code which can read the subscription databases can also read the GeoLite databases.
Warning: there are many cities with the same name so joins will have to be carefully executed.
I uploaded the entire database to a Google Fusion Table, which is designed to look through large databases; in this case 419,433 rows of cities.
The GeoLite City Location columns:
- Postal Code
- Metro Code (if applicable)
- Area Code (if applicable)
I came across this because I was having a hard time finding a good geocoder to get the information I wanted. This is a geocoder hack-around, basically. Enjoy!