Skip to content

Commit

Permalink
Get correct list of constituencies
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed Aug 16, 2014
1 parent 3431cd0 commit 6c293ec
Show file tree
Hide file tree
Showing 3 changed files with 1,993 additions and 2 deletions.
26 changes: 26 additions & 0 deletions bin/load_constit
@@ -0,0 +1,26 @@
#!/usr/bin/perl

use strict;
use warnings;
use 5.010;
use lib 'lib';

use JSON;
use TwittElection::Schema;

open my $js_fh, '<', 'db/constit.json' or die $!;

my $json = join '', <$js_fh>;

my $data = decode_json($json);

my $sch = TwittElection::Schema->connect(
"dbi:mysql:$ENV{TE_DB}", $ENV{TE_USER}, $ENV{TE_PASS},
{ mysql_enable_utf8 => 1 },
) or die;

my $con_rs = $sch->resultset('Constituency');

foreach (@$data) {
$con_rs->create({ name => $_->{name}, list_name => $_->{name} });
}

0 comments on commit 6c293ec

Please sign in to comment.