Import the World Database into Redis

World database for Redis

I often need some dummy data for my tests and, as used as I am to import the SQL dump of the [world database](https://dev.mysql.com/doc/world-setup/en/) into MySQL, I wanted to make consistent tests and examples against the same simple dataset. So I converted the three tables of this dataset into Redis commands, so you can import the data should you need it. The entities storing the data are Hashes.

127.0.0.1:6379> HGETALL city:653
1) "Name"
2) "Madrid"
3) "CountryCode"
4) "ESP"
5) "District"
6) "Madrid"
7) "Population"
8) "2879052"

As reported in the source database, the world database is Copyright Statistics Finland, http://www.stat.fi/worldinfigures.

Visit my [world GitHub repository](https://github.com/mortensi/world).

Usage

  1. Download the world.txt file
  2. Import into Redis with cat world.txt | redis-cli

Notes

  • All the entities are stored as Redis Hashes
  • The database presents three entities: city, country, countrylanguage
  • city‘s unique key is an autoincrement integer, e.g. city:653
  • country‘s unique key is the country code, e.g. country:esp
  • countrylanguage‘s unique key is an autoincrement integer, e.g. countrylanguage:6

Leave A Comment