Mailing List Archive

Persistent connection
I'm testing different aspects of embperl and modperl programming for a project
I have.

One of these aspects is database programming. I like the DBIx::Recordset
approach to get several items, but for complex updates and single-value
selects, DBI seems better.

Well, my questions is how I will make only one connect to the database instead
of connecting for each and every query. I believe there must be a simple
solution to this, but it's nowhere to be found in the Embperl dox. Maybe it
belongs somewhere else; could someone give me a pointer to a good place to look?

--
Kaare Rasmussen --Linux, spil,-- Tlf: 3816 2582
Kaki Data tshirts, merchandize Fax: 3816 2582
Howitzvej 75 Åben 14.00-18.00 Email: kar@webline.dk
2000 Frederiksberg Lørdag 11.00-17.00 Web: www.suse.dk
RE: Persistent connection [ In reply to ]
> I'm testing different aspects of embperl and modperl programming
> for a project
> I have.
>
> One of these aspects is database programming. I like the DBIx::Recordset
> approach to get several items, but for complex updates and single-value
> selects, DBI seems better.
>
> Well, my questions is how I will make only one connect to the
> database instead
> of connecting for each and every query. I believe there must be a simple
> solution to this, but it's nowhere to be found in the Embperl
> dox. Maybe it
> belongs somewhere else; could someone give me a pointer to a good
> place to look?
>

When running under mod_perl use Apache::DBI. Also you can create one
DBIx::Database object at the start of your script and specify the !KeepOpen
flag. Afterwards you give this Database object as !DataSource when you
create a new Recordset object, or retrive the database handle via the method
DBHdl to make a normal DBI query, update etc.

Gerald


-------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 925151
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------
RE: Persistent connection [ In reply to ]
> When running under mod_perl use Apache::DBI. Also you can create one
> DBIx::Database object at the start of your script and specify the !KeepOpen
> flag. Afterwards you give this Database object as !DataSource when you
> create a new Recordset object, or retrive the database handle via the method
> DBHdl to make a normal DBI query, update etc.

Thanks for your reply.

I have two concerns though. Can I use the same connection for _both_ DBI and
DBIx ?
The other question is that my script is short-lived, with only one transaction
per instance. I would like to keep the database connection alive "always". Is
this a feature of Apache::DBI ?

--
Kaare Rasmussen --Linux, spil,-- Tlf: 3816 2582
Kaki Data tshirts, merchandize Fax: 3816 2582
Howitzvej 75 Åben 14.00-18.00 Email: kar@webline.dk
2000 Frederiksberg Lørdag 11.00-17.00 Web: www.suse.dk
RE: Persistent connection [ In reply to ]
>
> I have two concerns though. Can I use the same connection for
> _both_ DBI and
> DBIx ?

Yes, you can retrieve the database handle via the method DBHdl from any
Recordset or Database object.

> The other question is that my script is short-lived, with only
> one transaction
> per instance. I would like to keep the database connection alive
> "always". Is
> this a feature of Apache::DBI ?
>

Yes

Gerald