• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 487
  • Last Modified:

Perl DBI Pooling

http://search.cpan.org/~timb/DBI-1.627/DBI.pm

When using this, is some kind of reuse of database connections implemented automatically, or database pooling of some sort? I did a quick search for the word pool, and found a dead link to http://search.cpan.org/perldoc?DBI%3A%3APool
0
itnifl
Asked:
itnifl
  • 3
  • 2
4 Solutions
 
Dave BaldwinFixer of ProblemsCommented:
If there is, it would have to be implemented in the drivers.  DBI depends on the drivers for things like that.  Two different databases would not have the same driver and protocol so you couldn't pool them but you could still connect to both of them in the same program using DBI.

http://search.cpan.org/~timb/DBI-1.627/DBI.pm#connect
0
 
itniflAuthor Commented:
Yes, I forgot to mention that I am connecting to mysql.
0
 
Dave BaldwinFixer of ProblemsCommented:
You'd have to look at the MySQL driver for any connection pooling.  It's not going to be in DBI itself because DBI is a standardized interface for many databases.  Here's the page for the MySQL driver: http://search.cpan.org/dist/DBD-mysql/
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
itniflAuthor Commented:
I know when connecting to mysql with C# I set up connection pooling in the connection string. I guess that might have been specific for the drivers C# uses? I'll take a look at your link :)
0
 
Dave BaldwinFixer of ProblemsCommented:
I believe that in C# you are going directly to the driver.  DBI does not provide for that.  DBI is an interface between your program and the driver.
0
 
wilcoxonCommented:
If DBD::mysql does not provide connection pooling (most DBD drivers I've looked at don't) then it is pretty easy to write it yourself.

DBI does provide connect_cached which may solve your issue directly within DBI.

In general, unless you have a very long-running program (or something that acts as a daemon), it is sufficient to open the connection when the program starts and let it auto-close when the program ends.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now