6 use Data::Dump qw/dump/;
9 my $riak_url = 'http://10.60.0.92:8098';
10 my $dbi = 'DBI:mysql:dbname=koha;host=10.60.0.10;port=3306';
16 my $dbh = DBI->connect($dbi,"","") || die $DBI::errstr;
17 my $riak = Net::Riak->new(host => $riak_url );
19 #my $marcxml_bucket = $riak->bucket( 'koha.marcxml' );
21 foreach my $table ( @tables ) {
23 my $sth = $dbh->prepare(qq{ select * from $table $limit}) || die $dbh->errstr();
24 $sth->execute || die $sth->errstr();
25 my @pk = $dbh->primary_key( undef, undef, $table );
27 print "import ", $sth->rows, " rows from $table pk:",dump( @pk ),"...\n";
29 my $bucket = $riak->bucket( 'koha.' . $table );
31 while (my $row = $sth->fetchrow_hashref() ) {
33 my $key = join('_', map { $row->{$_} } @pk);
35 if ( my $marcxml = delete $row->{marcxml} ) {
36 my $request = $riak->client->new_request(
37 'PUT', [ 'riak', "koha.marcxml/$key" ]
39 $request->header('Content-Type' => 'text/xml');
40 $request->content($marcxml);
41 my $response = $riak->client->send_request($request);
43 warn "$riak_url/riak/koha.marcxml/$key ", length($marcxml), " bytes\n";
45 unless ($response->is_success) {
46 die "Error put marcxml:", dump( $response );
50 warn "# $key ",dump($row);