Re: Cannot insert large files in MySQL from PERL
From: Michael A Chase tech (mchase_at_ix.netcom.com)
Date: 12/14/04
- Next message: Graeme St. Clair: "RE: Cannot insert large files in MySQL from PERL"
- Previous message: Oit: "Cannot insert large files in MySQL from PERL"
- In reply to: Oit: "Cannot insert large files in MySQL from PERL"
- Next in thread: Oit: "Re: Cannot insert large files in MySQL from PERL"
- Reply: Oit: "Re: Cannot insert large files in MySQL from PERL"
- Reply: Oit: "Re: Cannot insert large files in MySQL from PERL"
- Reply: Oit: "Re: Cannot insert large files in MySQL from PERL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 13 Dec 2004 18:26:13 -0800 To: OIT <lmaster1@broward.org>
On 12/13/2004 09:33 AM, OIT said:
> 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!!!
Is that a binary or text file? quote() is not likely to work correctly
on binary data.
> 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" . "'" . ")" . ";" ;
$sql = "INSERT INTO traces values ('$begin_datetime','$end_datetime'," .
"?,'$device_name','$device_port');";
It is not necessary to split the string up that much, all those dots
make my eyes cross and also make it hard to tell if the SQL is valid.
You should probably also pass the other values via placehloders.
> $sth = $dbh->prepare($sql);
> $file1=$dbh->quote("$var");
> $sth->bind_param( 1, $file1, SQL_LONGVARCHAR);
If you use a placeholder to pass the value, you shouldn't quote() it.
-- Mac :}) ** I usually forward private questions to the appropriate mail list. ** Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html Give a hobbit a fish and he eats fish for a day. Give a hobbit a ring and he eats fish for an age.
- Next message: Graeme St. Clair: "RE: Cannot insert large files in MySQL from PERL"
- Previous message: Oit: "Cannot insert large files in MySQL from PERL"
- In reply to: Oit: "Cannot insert large files in MySQL from PERL"
- Next in thread: Oit: "Re: Cannot insert large files in MySQL from PERL"
- Reply: Oit: "Re: Cannot insert large files in MySQL from PERL"
- Reply: Oit: "Re: Cannot insert large files in MySQL from PERL"
- Reply: Oit: "Re: Cannot insert large files in MySQL from PERL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|