in reply to Re: Putting mod Storable output into MySQL
in thread Putting mod Storable output into MySQL

Yes that did it. Thanks. I renamed key to id and blob to datastructure.

Now that I've gotten the blob into MySQL I'm having trouble getting it back out. When I do it like so

$command ='select datastructure from blobtest where id=1'; $sth = $dbh->prepare($command); @reply = $sth->execute || die "Could not execute MySQL statement: $com +mand"; my $reconstituted = thaw($reply[0][0]);
$reply[0][0] contains an integer 1. I don't think a placeholder is appropriate in this case, is it?

Replies are listed 'Best First'.
Re^3: Putting mod Storable output into MySQL
by pg (Canon) on Oct 15, 2005 at 18:36 UTC

    This is what you should do (the commented out part shows what was inserted):

    use Storable qw(freeze thaw); use DBI; use Data::Dumper; use strict; use warnings; my $dsn = "DBI:mysql:database=test;host=foo"; my $dbh = DBI->connect($dsn, 'root', 'abcd', {RaiseError => 1}); #my $data = {'a'=>1, 'b'=>{'c'=>2, 'd'=>3}, 'e'=>[1,2,3]}; #my $frozen = freeze($data); #my $command = "insert into test(a,b) values(10,?)"; #my $sth = $dbh->prepare($command); #$sth->execute($frozen); my $command = "select b from test where a = 10"; my $sth = $dbh->prepare($command); $sth->execute(); my $result = $sth->fetchrow_arrayref(); my $data = thaw($result->[0]); print Dumper($data);

    This prints:

    $VAR1 = { 'e' => [ 1, 2, 3 ], 'a' => 1, 'b' => { 'c' => 2, 'd' => 3 } };
      Duh. Thanks a million kind monk :-)