This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.
Subject: Problems with Apache::DBI
From: Webmast98@aol.com
Date: Mon, 12 Jun 2000 12:14:56 EDT
Hello,
This message is urgent and could save our banner exchange.
Recently we started growing so fast that we had to convert our entire system
at Traffic-Exchange.com to mysql. Now that this is done we need persistant
database connections to the mysql server. From downloading the Apache::DBI
module I have no idea how to set this up.
But what I can tell you is that we connect to the mysql database 1 time for
every banner that is called by having this in our perl script:
use DBI;
$dbh =
DBI->connect("dbi:mysql:$mysqldatabase","$mysqlusername","$mysqlpassword") ||
die("Couldn't connect to database!\n");
&updatedatabase;
$dbh->disconnect;
Each time a banner is called that code is execuited meaning the database
would open over 1,000 in a few min.
>From seeng this how is it that I can change this to use your module for
persistant connections and what is it I need to do.
The README was a bit confusing.
===
Subject: Re: Problems with Apache::DBI
From: Rob Tanner <rtanner@onlinemac.com>
Date: Mon, 12 Jun 2000 09:52:59 -0700
Believe it or not, it's the simplest task in the world. In startup.pl add
the line "PerlModule Apache::DBI" I'm not sure how it does it's magic, but
basically, with that module loaded, DBI connection open/close requests go
through it and it maintains a persistant connection for you (the close is
replaced with a null, etc, so you don't even have to modify your banner
module. If you've installed Apache::DBI, simply grab the manpage, but
basically, all you do is add it to startup.pl. Neat, ain't it!! :-)
===
Subject: RE: Problems with Apache::DBI
From: "John Keiser" <john@ieffects.com>
Date: Mon, 12 Jun 2000 10:54:18 -0600
From what I read about the module, it overrides connect() and checks if the
connection has already been made. Overrides disconnect to not actually
disconnect. Pretty darn nifty.
===
Subject: Re: Problems with Apache::DBI
From: Drew Taylor <dtaylor@vialogix.com>
Date: Mon, 12 Jun 2000 13:02:29 -0400
One other thing: Make sure the 'use Apache::DBI' comes before 'use DBI'
in your startup.pl or httpd.conf file. Very important little step. :-)
Other than that, it's a 5 minute drop in that works wonderfully!
===
Subject: Re: Problems with Apache::DBI
From: Matt Carothers <matt@telepath.com>
Date: Mon, 12 Jun 2000 14:29:37 -0500 (CDT)
On Mon, 12 Jun 2000, Rob Tanner wrote:
> Believe it or not, it's the simplest task in the world. In startup.pl add
> the line "PerlModule Apache::DBI"
You can either stick "PerlModule Apache::DBI" in your httpd.conf or add
'use Apache::DBI ();' to your startup.pl. Also, for mysql, you'll need
to add a keepalive routine to your startup.pl:
sub Apache::DBI::db::ping {
my $dbh = shift;
return $dbh->do('select 1');
}
===
Subject: Re: Problems with Apache::DBI
From: Edmund Mergl <E.Mergl@bawue.de>
Date: Mon, 12 Jun 2000 21:44:07 +0200
Matt Carothers wrote:
>
> On Mon, 12 Jun 2000, Rob Tanner wrote:
>
> > Believe it or not, it's the simplest task in the world. In startup.pl add
> > the line "PerlModule Apache::DBI"
>
> You can either stick "PerlModule Apache::DBI" in your httpd.conf or add
> 'use Apache::DBI ();' to your startup.pl. Also, for mysql, you'll need
> to add a keepalive routine to your startup.pl:
>
> sub Apache::DBI::db::ping {
> my $dbh = shift;
> return $dbh->do('select 1');
> }
>
> - Matt
this is safer:
sub Apache::DBI::db::ping {
my $dbh = shift;
my $ret = 0;
eval {
local $SIG{__DIE__} = sub { return (0); };
local $SIG{__WARN__} = sub { return (0); };
$ret = $dbh->do('select 1');
};
return ($@) ? 0 : $ret;
}
===
===
Subject: Re: Apache::DBI broken?
From: merlyn@stonehenge.com (Randal L. Schwartz)
Date: 16 Jun 2000 15:00:18 -0700
Perrin" == Perrin Harkins <perrin@primenet.com> writes:
Perrin> Make sure you're loading it before DBI, including any scripts that use
Perrin> DBI. Try putting "PerlModule Apache::DBI" right up at the top of your
Perrin> httpd.conf and see if that fixes things.
I'm hoping that some future version of Apache::DBI eliminates this
requirement, as it doesn't survive a reload very well.
This has been discussed on this mailing list before. Maybe someone
could provide the patch finally, so it gets done.
I'm not asking for an existing DBI handle to be cached, but any new
DBI handles should come from a pool once Apache::DBI has been seen.
===