-$dbh->do('TRUNCATE ratings');
-$dbh->do('COPY ratings ( id, rating, rating_stddev ) FROM STDIN');
-$dbh->pg_putcopydata(join("\n", @ratings));
-$dbh->pg_putcopyend();
+my $dbh = DBI->connect($config::local_connstr, $config::local_username, $config::local_password)
+ or die "connect: " . $DBI::errstr;
+$dbh->{AutoCommit} = 1;
+
+my @locales = wloh_common::find_all_locales($dbh);
+my @filenames = ();
+
+for my $locale (@locales) {
+ my $last_season = find_last_season($dbh, $locale);
+ my @games = ();
+ my %ids = ();
+ fetch_games($dbh, $locale, $last_season, \@games, \%ids);
+ my $tmpnam = output_to_file($locale, \@games, \%ids);
+ push @filenames, $tmpnam;
+}