I'm sorry I didn't explain an important component.  Since I am dealing with
a few hundred requests per minute (this was got me onto mod_perl to begin
with), then using DBI's ability to write to a file would vastly overwhelm my
system.

Thanks
Mark

-----Original Message-----
From: Robert Landrum [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 05, 2002 1:25 PM
To: Mark Hazen; [EMAIL PROTECTED]
Subject: Re: Breaks in mod_perl, works in Perl


At 1:14 PM -0700 3/5/02, Mark Hazen wrote:
>I am hoping there is a someone brilliant on this list that can help me.  A
>little while ago, I posted to clp.perl asking how I can capture the trace
>output from DBI into a variable.  Since DBI is an external process, I
>couldn't do it just by piping STDERR.  Benjamin Goldberg came up with a
>module called IO::Capture (see below).  It works amazingly well in standard
>Perl.  Here is a sample script:



Maybe I'm just crazy.... but wouldn't this be simpler?

use DBI;
$dbh = DBI->connect ("DBI:mysql:test:localhost", "username", "password", {
RaiseError => 0, PrintError => 0 });

$filename = "/tmp/dbi_".$$.time().rand(10000).".trace";

DBI->trace( 1, $filename );

$sth = $dbh->prepare (qq{
  CREATE TABLE IF NOT EXISTS test_table
  (
     a CHAR(15) NOT NULL,
     b INT UNSIGNED NOT NULL
  )
  });
$sth->execute ();
$sth->finish ();

$dbh->disconnect ();


print qq{
Output is:
};

open(FILE,$filename);
print while(<FILE>);
close(FILE);

The problem with the module listed is that it does some filehandle
munging on what is already a munged filehandler.  Meaning, it looks
like a filehandle, but it's really just a hook into something apache
is going to use to output stuff to the error log.

Hope that helps...

Rob

--
When I used a Mac, they laughed because I had no command prompt. When
I used Linux, they laughed because I had no GUI.

Reply via email to