Cannot insert large files in MySQL from PERL

From: Oit (lmaster1_at_broward.org)
Date: 12/13/04


To: dbi-users@perl.org
Date: Mon, 13 Dec 2004 12:33:02 -0500

I am trying to save windump network trace files in MySQL. The following
piece works, and am able to insert into MySQL, but only a small piece of
this 50MB file is in there!!!

Does anybody know what would be truncating my file?

open($fh, '12-6-2004---15-49-29' ) or die $!;
   read( $fh, $var, -s $fh);

  $sql = "INSERT INTO traces values (" . "'" . "$begin_datetime" . "'" . ","
. "'" . "$end_datetime" . "'" . "," . "?" . "," . "'" . "$device_name" .
"'" . "," . "'" . "$device_port" . "'" . ")" . ";" ;

  $sth = $dbh->prepare($sql);

  $file1=$dbh->quote("$var");

  $sth->bind_param( 1, $file1, SQL_LONGVARCHAR);

  print "$sql \n";

  $numrows = $sth->execute();

  $sth->finish;

  print "$numrows \n";

  $dbh->disconnect;