[mod_python] MySQLDb or SQLObject connection pooling snippet wanted

Joshua "Jag" Ginsberg listspam at flowtheory.net
Thu Oct 12 09:31:38 EDT 2006


You're going to have difficulty with implementing a pure db connection
pooling solution simply b/c Apache is a forking webserver -- you can't
pass SQL connection objects between processes. If you're doing only one
thread per process, you can simply implement a connection object as a
Singleton class -- then it will get destroyed as the process gets
recycled. If you're doing multiple threads per process, you're going to
have to be a bit more clever.

I know it's sexy as hell to do connection pooling, but is DB connection
overhead really such a bottleneck for you? Folks who absolutely,
positively need the benefits of a shared-memory, multi-threaded,
thread-safe webserver usually pick something like AOLServer ("AOLServer
-- Heehee! It tickles!" -- sorry, bad joke).

-jag

On Thu, 2006-10-12 at 08:55 -0400, Sells, Fred wrote:
> Currently using mod_python 3.1.x and Apache 2.x.  Could upgrade mod_python
> if we must, but this is what apt-get gives us.
> 
> I would like to implement connection pooling for the MySQL database.  Based
> on the application requirements, we vary between MySQLDb and SQLObject.
> 
> The only reference I've found so far is jonpy.sourceforge.net Does anyone
> have any "better" modules or any experience with this one?
> 
> ---------------------------------------------------------------------------
> The information contained in this message may be privileged and / or
> confidential and protected from disclosure. If the reader of this message is
> not the intended recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited. If you
> have received this communication in error, please notify the sender
> immediately by replying to this message and deleting the material from any
> computer.
> ---------------------------------------------------------------------------
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list