David Wheeler wrote:
Can you send me the script and the data you're trying to insert? Thanks, David
My pleasure.
#!/usr/bin/perl -w
use DBI;
use IO;
use IO::File;
use strict;
my $dbh = DBI->connect ('dbi:Pg:dbname=shop-devel', 'cbraga', undef, { AutoCommit =>
0, RaiseError => 1, PrintError => 1 } ) || die DBI->errstr;
my $fh = new IO::File (shift (), "r");
my $data = '';
my $datasize = 0;
my $data2;
while (my $rd = read $fh, $data2, 65536) {
$data .= $data2;
$datasize += $rd;
}
my $ins = $dbh->prepare ('INSERT INTO binfile (size, data) VALUES (?, ?)');
$ins->execute ($datasize, $data);
$dbh->commit;
$ins->finish;
$dbh->disconnect;
<<inline: blank.png>>
