--- /dev/null
+#! /usr/bin/perl
+use strict;
+use warnings;
+
+# Parses country list from
+# http://en.wikipedia.org/w/index.php?title=List_of_IOC_country_codes&action=edit
+
+print "begin;\n";
+
+while (<>) {
+ m/
+ ^ \* \s*
+ ( [A-Z]{3} ) # country code
+ \s* - \s*
+ \[\[
+ ( ?: .*? \| ) ? # optional article lookup
+ ( .*? ) # country name
+ \]\]
+ /x or next;
+
+ my ($countrycode, $countryname) = ($1, $2);
+
+ # fix some wikisyntax ickyness :-)
+ $countryname =~ s/\]\]//g;
+ $countryname =~ s/\[\[//g;
+
+ # minimal SQL escaping
+ $countryname =~ s/'/\\'/g;
+
+ printf "INSERT INTO countries (countryname,countrycode) VALUES ('%s','%s');\n",
+ $countryname, $countrycode;
+}
+
+printf "commit;\n";