in reply to Putting mod Storable output into MySQL
The problem is that: your column name (for example, "key") clashed with mysql keywords. I can reproduce your issue, if I follow your column names, but once I rename the columns to a and b, the problem is gone:
use Storable qw(freeze); use DBI; use strict; use warnings; my $dsn = "DBI:mysql:database=test;host=foo"; my $dbh = DBI->connect($dsn, 'root', 'password', {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(1,?)"; my $sth = $dbh->prepare($command); $sth->execute($frozen);
Your problem can be easily reproduced (without Storable):
use DBI; use strict; use warnings; my $dsn = "DBI:mysql:database=test;host=foo"; my $dbh = DBI->connect($dsn, 'root', 'abcd', {RaiseError => 1}); my $frozen = "1"; my $command = "insert into test(key,b) values(1,?)"; my $sth = $dbh->prepare($command); $sth->execute($frozen);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Putting mod Storable output into MySQL
by cormanaz (Deacon) on Oct 15, 2005 at 18:16 UTC | |
by pg (Canon) on Oct 15, 2005 at 18:36 UTC | |
by cormanaz (Deacon) on Oct 15, 2005 at 23:17 UTC |