Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

Apache::DBI

 

 

First page Previous page 1 2 3 Next page Last page  View All ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


jim at rollercoaster

May 3, 2000, 7:02 AM

Post #1 of 58 (3264 views)
Permalink
Apache::DBI

I'm not sure if this is even a problem but it's always
been on my mind. I use Apache::DBI and I have a general
module that handles db connections for my scripts. Here's
the relevant portion:

my $DBH ||= DBI->connect("...")

It basically accepts a hash ref to the dbconfig and opens
a connection. My httpd.conf is set with 5 spare clients
MIN and 10 MAX.

I'm the only one using this module right now and starting
httpd fresh results in no conections. Running my test CGI
script once results in two (2) mysql connections. Running
it again, results in four (4) connections. This will
eventually continue until the number of mysql connections
is always four (4) more than httpd processes.

The thing that I can't figure out is that my scripts
properly open and close the db connection, so why doesn't
Apache::DBI re-use the original connection? Why spawn
one more each time?

I've checked the FAQ and searched the archives and found
no info (other than someone else asking this same question
last year with no helpful answer) and the Apache:DBI man
page doesn't touch on this.

Jim


jim at rollercoaster

May 3, 2000, 7:19 AM

Post #2 of 58 (3182 views)
Permalink
Re: Apache::DBI [In reply to]

> Are you sure it's not:
> Opening connections with different parameters
> http://perl.apache.org/guide/databases.html#Opening_connections_with_differe

Oops. I forgot I had two seperate db accesses on this
particular page and running with $Apache::DBI::DEBUG = 1
clued me in. So am I correct in saying that it will
continue to open connections until connections = httpd
processes? It seems like that's what's eventually happening.

Jim


sbekman at stason

May 3, 2000, 8:29 AM

Post #3 of 58 (3188 views)
Permalink
Re: Apache::DBI [In reply to]

On Wed, 3 May 2000, Jim Serio wrote:

> I'm not sure if this is even a problem but it's always
> been on my mind. I use Apache::DBI and I have a general
> module that handles db connections for my scripts. Here's
> the relevant portion:
>
> my $DBH ||= DBI->connect("...")
>
> It basically accepts a hash ref to the dbconfig and opens
> a connection. My httpd.conf is set with 5 spare clients
> MIN and 10 MAX.
>
> I'm the only one using this module right now and starting
> httpd fresh results in no conections. Running my test CGI
> script once results in two (2) mysql connections. Running
> it again, results in four (4) connections. This will
> eventually continue until the number of mysql connections
> is always four (4) more than httpd processes.
>
> The thing that I can't figure out is that my scripts
> properly open and close the db connection, so why doesn't
> Apache::DBI re-use the original connection? Why spawn
> one more each time?
>
> I've checked the FAQ and searched the archives and found
> no info (other than someone else asking this same question
> last year with no helpful answer) and the Apache:DBI man
> page doesn't touch on this.

Are you sure it's not:
Opening connections with different parameters
http://perl.apache.org/guide/databases.html#Opening_connections_with_differe

______________________________________________________________________
Stas Bekman | JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ | mod_perl Guide http://perl.apache.org/guide
mailto:stas [at] stason | http://perl.org http://stason.org/TULARC/
http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org
----------------------------------------------------------------------


gyoung at laserlink

May 3, 2000, 10:03 AM

Post #4 of 58 (3174 views)
Permalink
RE: Apache::DBI [In reply to]

> -----Original Message-----
> From: Jim Serio [mailto:jim [at] rollercoaster]
> Sent: Wednesday, May 03, 2000 10:02 AM
> To: modperl [at] apache
> Subject: Apache::DBI
>
>
> I'm not sure if this is even a problem but it's always
> been on my mind. I use Apache::DBI and I have a general
> module that handles db connections for my scripts. Here's
> the relevant portion:
>
> my $DBH ||= DBI->connect("...")
>
> It basically accepts a hash ref to the dbconfig and opens
> a connection. My httpd.conf is set with 5 spare clients
> MIN and 10 MAX.
>
> I'm the only one using this module right now and starting
> httpd fresh results in no conections. Running my test CGI
> script once results in two (2) mysql connections. Running
> it again, results in four (4) connections. This will
> eventually continue until the number of mysql connections
> is always four (4) more than httpd processes.
>
> The thing that I can't figure out is that my scripts
> properly open and close the db connection, so why doesn't
> Apache::DBI re-use the original connection? Why spawn
> one more each time?

try setting $Apache::DBI::DEBUG=2 to debug your connections.

any call to $dbh->disconnect is intercepted by Apache::DBI, thus no
disconnect ever really happens (which is the whole point to Apache::DBI)

Keep in mind that Apache::DBI will hold one connection per httpd child
process _per connect string_. That is, if you connect once with,say,
RAISE_ERROR=1 and once with RAISE_ERROR=0, Apache::DBI will create two
processes for that child.

HTH

--Geoff

>
> I've checked the FAQ and searched the archives and found
> no info (other than someone else asking this same question
> last year with no helpful answer) and the Apache:DBI man
> page doesn't touch on this.
>
> Jim
>


madmardy at madmardy

May 22, 2000, 7:01 PM

Post #5 of 58 (3183 views)
Permalink
Re: Apache::DBI [In reply to]

I have tried pulling in *any* DBI or DBD module one at a time and ALL of them
cause the server to fail to start. There is no error log message. This is
true whether I use the PerlModule config directive, or 'use' the module in the
script defined in the PerlScript directive. I have other modules in the
script, and until the database module is used, it starts OK. Is there an
order I must use them in? Apache::DBI installed without a hitch, are there
other pitfalls of which I should be aware?

Perrin Harkins wrote:

> On Mon, 22 May 2000, Mark Holt wrote:
>
> > Newbie to the list, apologies if this is a FAQ, but I checked the
> > archives...
> > I built a modperl-enabled server, (Apache/1.3.9 Ben-SSL/1.37 (Unix)
> > mod_perl/1.21) and have been running it for some time. I have the
> > mod_perl as a shared module, and I recently enabled it to start
> > development. I have a startup script in operation and things work fine,
> > until I try to preload any sort of DBI module. I tried Mysql,
> > DBI::mysql, Apache::DBI, all to no avail. The server gives no error
> > message, it simply acts as though it is starting, but does not show up
> > in the process list. Is there something I'm missing?
>
> Are you pulling in the DBI and DBD modules in your startup.pl? Is there
> any message in the error_log? Apache::DBI is not at all like DBD::mysql,
> so it sounds like you may have a problem totally unrelated to DBI.
>
> - Perrin


perrin at primenet

May 22, 2000, 7:09 PM

Post #6 of 58 (3188 views)
Permalink
Re: Apache::DBI [In reply to]

On Mon, 22 May 2000, Mark Holt wrote:

> I have tried pulling in *any* DBI or DBD module one at a time and ALL
> of them cause the server to fail to start. There is no error log
> message.

Does DBI work for you from command-line scripts? Did the tests for
DBD::mysql pass?

> Is there an order I must use them in? Apache::DBI installed without a
> hitch, are there other pitfalls of which I should be aware?

Yes, the Apache::DBI docs explain that you must load it before any other
DBI-related modules.

- Perrin


gyoung at laserlink

Jun 21, 2000, 11:31 AM

Post #7 of 58 (3165 views)
Permalink
RE: Apache::DBI [In reply to]

> -----Original Message-----
> From: Eric Jain [mailto:jain [at] gmx]
> Sent: Wednesday, June 21, 2000 1:30 PM
> To: Mod_Perl
> Subject: Apache::DBI
>
>
> Is it be possible to modify Apache::DBI in sich a way that only
> database connections specified in a PerlRequired startup.pl with
> Apache::DBI->connect_on_init(...) are stored and all subsequent
> DBI->connect(...) connections are properly established (if no matching
> stored connection is available), but not stored afterwards?

I'm not sure why you would want to do such a thing, but I don't think it
fits with DBI/Apache::DBI's model...

why exactly are you looking for this behavior?

--Geoff

> Or could
> Apache::DBI::db::disconnect be changed, so it would actually
> disconnect, except if it was handling one of the connect_on_init
> connections?
>
>
> --
> Eric Jain
>


jain at gmx

Jun 21, 2000, 1:08 PM

Post #8 of 58 (3166 views)
Permalink
RE: Apache::DBI [In reply to]

> > Is it be possible to modify Apache::DBI in sich a way that only
> > database connections specified in a PerlRequired startup.pl with
> > Apache::DBI->connect_on_init(...) are stored and all subsequent
> > DBI->connect(...) connections are properly established
> (if no matching
> > stored connection is available), but not stored afterwards?
>
> I'm not sure why you would want to do such a thing, but I
> don't think it
> fits with DBI/Apache::DBI's model...
>
> why exactly are you looking for this behavior?

Currently I don't use Apache::DBI, even though 99% of all connections
are made as the same user, since I have a few users log in and connect
with their own usernames. This would lead to every process having
several open connections, using up lots of precious RAM...


--
Eric Jain


perrin at primenet

Jun 21, 2000, 2:47 PM

Post #9 of 58 (3169 views)
Permalink
RE: Apache::DBI [In reply to]

On Wed, 21 Jun 2000, Eric Jain wrote:

> > > Is it be possible to modify Apache::DBI in sich a way that only
> > > database connections specified in a PerlRequired startup.pl with
> > > Apache::DBI->connect_on_init(...) are stored and all subsequent
> > > DBI->connect(...) connections are properly established
> > (if no matching
> > > stored connection is available), but not stored afterwards?
> >
> > I'm not sure why you would want to do such a thing, but I
> > don't think it
> > fits with DBI/Apache::DBI's model...
> >
> > why exactly are you looking for this behavior?
>
> Currently I don't use Apache::DBI, even though 99% of all connections
> are made as the same user, since I have a few users log in and connect
> with their own usernames. This would lead to every process having
> several open connections, using up lots of precious RAM...

If you just want a quick hack to make this work, you could put in a quick
check in the connect method of Apache::DBI which would skip caching
connections that use a username other than one you specify in your
startup.pl. Should be easy to implement.

- Perrin


davem at fdgroup

Jun 26, 2000, 2:06 AM

Post #10 of 58 (3188 views)
Permalink
Re: Apache::DBI [In reply to]

> But I run apache I get:
> utechnology# ./apachectl start
> defined(@array) is deprecated at
> /usr/local/lib/perl5/site_perl/5.6.0/Apache/DBI.pm line 135.
> (Maybe you should just omit the defined()?)
> ./apachectl start: httpd started

Perl 5.6.0 has introduced a new warning when it sees code like
if (defined @array) ...
which is technically wrong, and should be changed to

if (@array) ...
A suprising number of Perl modules have got code like this in them;
it is usually just a simple matter of editing the offending lines.

Over time, I should imagine that the various module owners will release
new versions that dont generate this warning.


* Dave Mitchell, Operations Manager,
* Fretwell-Downing Facilities Ltd, UK. Dave.Mitchell [at] fdgroup
* Tel: +44 114 281 6113. The usual disclaimers....
*
* Standards (n). Battle insignia or tribal totems


guobin_ at yahoo

Jul 2, 2000, 6:18 PM

Post #11 of 58 (3169 views)
Permalink
Re: apache::DBI [In reply to]

Though not using rh 6.2, my experience on 6.1 was the
same --- apache will crash whenever use Apache::DBI
is included in httpd.conf. I'm now using manually
compiled apache and modperl and they are working fine.
Hope this will also work for 6.2.

On small glitch, Apache::Status cannot show Apache::DBI
connections on rh 6.1 i386, while the same setting works
on a rh 6.1 sparc!
--
Guo Bin

--- Christopher Suarez <dt98chsu [at] forsmark> wrote:
> I'm running rh linux 6.2 on a laptop and have tried for
> sometime to get
> apache::DBI runnning.
>
> modperl wokrs fine with apache but when I add the line
>
> PerlModule Apache::DBI to srm.conf, httpd.conf or "use
> Apache::DBI" to
> startup.pl and then PerlRequire /path/startup.pl to
> httpd.conf it won't
> work. apache will start ok(saying it's using mod_perl)
> but won't shut down
> ok and error_log doesn't
> say anythings wrong.
> the webserver won't response on contacting 127.0.0.1 in a
> browser it'll
> response connection refused.
>
> versions:
>
> apache-1.3.12-2
> apache-devel-1.3.12-2
> perl-2.00503-10
> perl-DBI-1.13-1
> perl-DBD-msql-mysql-1.2210-1
> perl-Apache-DBI-0.01-2
> perl-Apache-DBILogin-1.5-2
> perl-Apache-DBILogger-0.93-2
> perl-Apache-RedirectDBI-0.01-2
> mod_perl-1.21-10
> strange???
>


__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/


Kris at VersionOne

Jul 3, 2000, 3:06 PM

Post #12 of 58 (3174 views)
Permalink
RE: apache::DBI [In reply to]

Okay, so if it seems that Redhat 6.1/6.2 Apache & mod_perl is broken..
Anyone have a good guide/website to get apache & mod_perl compiled properly?
I've been reading the fine manuals and compiled httpd with mod_perl (by
using the Makefile.PL from the mod_perl src tree.)

When I list the modules compiled in the httpd, I do see the mod_perl.c ,
however, trying to get the server up and running just fails. It does the
same thing as I would add the keyword
PerlModule Apache::DBI in the httpd.conf from the out-of-the-box apache &
mod_perl from redhat 6.2 (the httpd seems to load, but it dies, because I'm
unable to telnet on port 80 and there are no logs of the crash).

Help?


-----Original Message-----
From: Guo Bin [mailto:guobin_ [at] yahoo]
Sent: July 2, 2000 9:18 PM
To: Christopher Suarez; modperl [at] apache
Subject: Re: apache::DBI


Though not using rh 6.2, my experience on 6.1 was the
same --- apache will crash whenever use Apache::DBI
is included in httpd.conf. I'm now using manually
compiled apache and modperl and they are working fine.
Hope this will also work for 6.2.

On small glitch, Apache::Status cannot show Apache::DBI
connections on rh 6.1 i386, while the same setting works
on a rh 6.1 sparc!
--
Guo Bin

--- Christopher Suarez <dt98chsu [at] forsmark> wrote:
> I'm running rh linux 6.2 on a laptop and have tried for
> sometime to get
> apache::DBI runnning.
>
> modperl wokrs fine with apache but when I add the line
>
> PerlModule Apache::DBI to srm.conf, httpd.conf or "use
> Apache::DBI" to
> startup.pl and then PerlRequire /path/startup.pl to
> httpd.conf it won't
> work. apache will start ok(saying it's using mod_perl)
> but won't shut down
> ok and error_log doesn't
> say anythings wrong.
> the webserver won't response on contacting 127.0.0.1 in a
> browser it'll
> response connection refused.
>
> versions:
>
> apache-1.3.12-2
> apache-devel-1.3.12-2
> perl-2.00503-10
> perl-DBI-1.13-1
> perl-DBD-msql-mysql-1.2210-1
> perl-Apache-DBI-0.01-2
> perl-Apache-DBILogin-1.5-2
> perl-Apache-DBILogger-0.93-2
> perl-Apache-RedirectDBI-0.01-2
> mod_perl-1.21-10
> strange???
>


__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/


daveh at hodgkinson

Jul 4, 2000, 2:01 AM

Post #13 of 58 (3170 views)
Permalink
Re: apache::DBI [In reply to]

Kristopher Lalletti <Kris [at] VersionOne> writes:

> Okay, so if it seems that Redhat 6.1/6.2 Apache & mod_perl is broken..
> Anyone have a good guide/website to get apache & mod_perl compiled
> properly?

http://perl.apache.org/guide/install.html#Installing_mod_perl_in_10_Minute

> I've been reading the fine manuals and compiled httpd with mod_perl (by
> using the Makefile.PL from the mod_perl src tree.)

I have to say that RH6.2 and mod_perl "works for me" out of the box,
at least in development. I'll let you know what it's like in
production in a few weeks... ;-)


You have all this carp in your httpd.conf? What does "apachectl
configtest" tell you?

LoadModule perl_module modules/libperl.so
AddModule mod_perl.c
PerlRequire startup.pl
<IfModule mod_perl.c>
Alias /perl/ /home/httpd/perl/
<Location /perl>
SetHandler perl-script
PerlHandler Apache::Registry
Options +ExecCGI
</Location>
</IfModule>

--
Dave Hodgkinson, http://www.hodgkinson.org
Editor-in-chief, The Highway Star http://www.deep-purple.com
Apache, mod_perl, MySQL, Sybase hired gun for, well, hire
-----------------------------------------------------------------


kclark at logsoft

Jul 26, 2001, 7:01 AM

Post #14 of 58 (3169 views)
Permalink
Re: Apache::DBI [In reply to]

On Thu, 26 Jul 2001, Castellon, Francisco wrote:

> Date: Thu, 26 Jul 2001 07:48:14 -0600
> From: "Castellon, Francisco" <castellon.francisco [at] syncrude>
> To: modperl [at] apache
> Subject: Apache::DBI
>
> Does anyone know if Apache::DBI is included with mod_perl? if not
> could someone tell me where i could get it from?
>

http://cpan.org/

ky


will at serensoft

Jul 29, 2001, 10:21 PM

Post #15 of 58 (3172 views)
Permalink
Re: Apache::DBI [In reply to]

On Thu, Jul 26, 2001 at 07:48:14AM -0600, Castellon, Francisco wrote:
> Does anyone know if Apache::DBI is included with mod_perl? if not
> could someone tell me where i could get it from?

if you're using DEBIAN, you find it like this:

$ dpkg -S Apache::DBI
libapache-dbi-perl: /usr/share/man/man3/Apache::DBI.3pm.gz
libapache-dbilogger-perl: /usr/man/man3/Apache::DBILogger.3pm.gz

so (as root) you'd just

# apt-get install libapache-dbi-perl

and you're off to the races.

--
I'd concentrate on "living in the now" because it is fun
and on building a better world because it is possible.
- Tod Steward

will [at] serensoft
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!


mithun.b at egurucool

Jul 29, 2001, 11:38 PM

Post #16 of 58 (3177 views)
Permalink
Re: Apache::DBI [In reply to]

Any particular reason why CPAN is not being suggested ???

> if you're using DEBIAN, you find it like this:
>
> $ dpkg -S Apache::DBI


will at serensoft

Aug 4, 2001, 5:42 AM

Post #17 of 58 (3190 views)
Permalink
Re: Apache::DBI [In reply to]

On Mon, Jul 30, 2001 at 12:08:26PM +0530, Mithun Bhattacharya wrote:
> Any particular reason why CPAN is not being suggested ???
> > if you're using DEBIAN, you find it like this:
> >
> > $ dpkg -S Apache::DBI

very particular.

we debian folks are spoiled. nice packaging system they have
here. it tracks versions and inter-dependencies.

cpan is likely to give you the latest-and-greatest which may
need an upgrade of something else that will require a new
rendition of this, which needs a whole new perl, which might
just break every bloomin' thing you've got.

*if* you can stick with the debian packages, you can stay snug
and safe back with the stable distro, where older (calmer,
robuster, stabler, not-as-fancy-but-at-least-as-solid) versions
can be had for the asking.

and i hear that current CPAN downloads can be folded into the
*.deb paradigm, but i'm not up on that aspect.

CPAN is great for red hat users (for example) who don't mind
breaking things ... or who are at least used to breaking things
often and easily. debian's package manager is a bit more
advanced than that.

--
Khan said that revenge is a dish best served cold. I think
sometimes it's best served hot, chunky, and foaming.
- P.J.Lee ('79-'80)

will [at] serensoft
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!


mithun.b at egurucool

Aug 4, 2001, 9:02 AM

Post #18 of 58 (3175 views)
Permalink
Re: Apache::DBI [In reply to]

Shakes his head and hopes you will someday get enlightened as to the
purpose of CPAN.


Mithun

--------
> CPAN is great for red hat users (for example) who don't mind breaking things


will at serensoft

Aug 15, 2001, 11:50 AM

Post #19 of 58 (3173 views)
Permalink
Re: Apache::DBI [In reply to]

On Sat, Aug 04, 2001 at 09:32:43PM +0530, Mithun Bhattacharya wrote:
> Shakes his head and hopes you will someday get enlightened as to the
> purpose of CPAN.
>
> --------
> > CPAN is great for red hat users (for example) who don't mind breaking things

let's not condescend too quickly -- when you finally come up for
air you might just get the bends...

here's my level of enlightenment on the purpose of cpan -- see if
i'm off (and if so, please illuminate):

cpan is where you can get perl modules. install the CPAN perl
module itself and you have handy command-line access to
downloading, building, testing and installing any perl module
you could care to shake a stick at.

this will cause no more problems on just about any linux distro
than doing a normal rpm install.

but if you're on debian, you're bypassing debian's advanced
packaging tool with all its inter-dependency info. on debian we
can get the appropriate version of package ABC /for our system/
(old-fashioned/anal "stable" [that's where you find me] vs
wanderlust-driven "testing" vs bleeding-edge "unstable"). with
direct cpan access i'm not sure there's a way to download the old
version of module XYZ that utilizes the old QRS libraries i've
got on my system. (it may be possible, but debian packages take
care of all that for me, saving me lots of learning curve, if it
exists.)

this is an advantage we debianites enjoy, and it's hard to
explain to others.

apt-get install libxml-perl libapache-ssi-perl libhtml-mason-perl

at one time, the system setup i've got right now, was
state-of-the-art, somewhere. my system is basically a snapshot of
that moment in time. with apt-get, instead of the current latest
and greatest -- which might force me to upgrade something
significant before i'm ready -- i'd get the packages that works
with my current system.

unless i'm wrong.

--
Khan said that revenge is a dish best served cold. I think
sometimes it's best served hot, chunky, and foaming.
- P.J.Lee ('79-'80)

will [at] serensoft
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!


geoff at modperlcookbook

Feb 6, 2002, 12:54 PM

Post #20 of 58 (3181 views)
Permalink
Re: Apache::DBI [In reply to]

"Stathy G. Touloumis" wrote:
>
> I thought I saw a posting on how to retrieve an independent database handle
> from Apache::DBI using a certain method call (instead of from the shared
> $dbh for the child). Does anyone know where this documentation may reside
> (If it is possible).

I'm not sure what you mean, really, but perhaps you mean
dbi_connect_method?

from man DBI:

The "dbi_connect_method" attribute can be used to specify which driver
method should be called to establish
the connection. The only useful values are 'connect',
'connect_cached', or some specialized case like
'Apache::DBI::connect' (which is automatically the default when
running within Apache).

so, basically you can create a connection under Apache::DBI that is
_not_ cached using 'connect'.

is that what you meant?

--Geoff


stathy.touloumis at edventions

Feb 6, 2002, 1:06 PM

Post #21 of 58 (3195 views)
Permalink
RE: Apache::DBI [In reply to]

> dbi_connect_method?
>
> from man DBI:
>
> The "dbi_connect_method" attribute can be used to specify which driver
> method should be called to establish
> the connection. The only useful values are 'connect',
> 'connect_cached', or some specialized case like
> 'Apache::DBI::connect' (which is automatically the default when
> running within Apache).
>
> so, basically you can create a connection under Apache::DBI that is
> _not_ cached using 'connect'.

Is that using DBI->connect or Apache::DBI->connect . . .

My understanding is that using Apache::DBI pretty much overrides the
functionality of DBI->connect and returns an existing database handle if it
exists (based on parameters passed to method).

I want to be able to return a cached database handle from a method unless a
certain argument is passed. If this argument is present I would like to
return an independent database handle for perhaps performing transactions.


stathy.touloumis at edventions

Feb 6, 2002, 1:09 PM

Post #22 of 58 (3169 views)
Permalink
RE: Apache::DBI [In reply to]

> I'm not sure what you mean, really, but perhaps you mean
> dbi_connect_method?

Did you mean specifying this argument like so ?

DBI->connect( $driver, $u, $p, { dbi_connect_method=> 'connect' } );

I will see if this is what I am looking for. Thanks for the reference : )


geoff at modperlcookbook

Feb 6, 2002, 1:21 PM

Post #23 of 58 (3180 views)
Permalink
Re: Apache::DBI [In reply to]

"Stathy G. Touloumis" wrote:
>
> > I'm not sure what you mean, really, but perhaps you mean
> > dbi_connect_method?
>
> Did you mean specifying this argument like so ?
>
> DBI->connect( $driver, $u, $p, { dbi_connect_method=> 'connect' } );

yes, you never call Apache::DBI->connect() directly.

>
> I will see if this is what I am looking for.

from what you described in your previous email, I would think it is.

> Thanks for the reference : )

sure :)

--Geoff


drfrog at telus

Feb 6, 2002, 1:29 PM

Post #24 of 58 (3200 views)
Permalink
Re: Apache::DBI [In reply to]

"Stathy G. Touloumis" wrote:
>
> > I'm not sure what you mean, really, but perhaps you mean
> > dbi_connect_method?
>
> Did you mean specifying this argument like so ?
>
> DBI->connect( $driver, $u, $p, { dbi_connect_method=> 'connect' } );
>
> I will see if this is what I am looking for. Thanks for the reference : )

this is how i usually do it in startup.pl:

#dont declare DBI!!!!
use Apache::DBI;

# Initialize the database connections for each child
Apache::DBI->connect_on_init
("DBI:mysql:database=Ezines;host=localhost",
"root","database",
{
PrintError => 1, # warn() on errors
RaiseError => 0, # don't die on error
AutoCommit => 1, # commit executes immediately
}
);

$Apache::DBI::DEBUG = 1;


then in my code i just use DBI as i normally would:


my $dbh =
DBI->connect(

'dbi:mysql(RaiseError=>1,Taint=>1):dbname=database;host=localhost',
'username', 'password', );

my $count = $dbh->selectrow_array( q{
SELECT
count(*)
FROM
Ezines
},
{},
);


$dbh->disconnect;




if you tail the log file you should see Apache::DBI::DEBUG messages


etothex at eudoramail

Feb 12, 2002, 8:16 PM

Post #25 of 58 (3182 views)
Permalink
Re: Apache::DBI [In reply to]

I had tried that, with the same result. (does
Apache::DBI overload the DBI methods?) Full
error is as follows. Again, any help is _highly_
appreciated.

Marty


[error] Can't locate object method "connect_on_init" via package "Apache::DBI" at /etc/httpd/conf/startup.pl line 28.
Compilation failed in require at (eval 14) line 1.

Syntax error on line 1276 of /usr/local/apache/conf/httpd.conf:
Can't locate object method "connect_on_init" via package "Apache::DBI" at /etc/httpd/conf/startup.pl line 28.
Compilation failed in require at (eval 14) line 1.

--

On Tue, 12 Feb 2002 08:44:12 Martin Haase-Thomas wrote:
>
>
>Marty J. Rogers wrote:
>
>>[snip]
>>>>From httpd.conf:
>>
>>PerlModule Apache::DBI CGI DBD::mysql \
>>Apache::AuthenDBI
>>PerlRequire /path/to/startup.pl
>>
>>Alias /perl/ /path/to/perl
>>PerlModule Apache::Registry
>><Location /perl>
>>SetHandler perl-script
>>PerlHandler Apache::Registry
>>Options ExecCGI
>>allow from all
>>PerlSendHeader On
>></Location
>>
>>
>>and from startup.pl:
>>
>>use DBI();
>>
> use Apache::DBI(); # !! :)
>
>>
>>use DBD::mysql();
>>.
>>.
>>.
>>DBI->connect_on_init("DBI:mysql:dbname",
>> "user","pass",
>> {Options here}
>>
>>
>>Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at http://www.eudoramail.com
>>
>
>
>


Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at http://www.eudoramail.com

First page Previous page 1 2 3 Next page Last page  View All ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.