I had some similar issues,

A python module runs the first time its called and then stays resident in the python 
interpreter for the duration of the app.
So anywhere you have a module you can define a new global variable.

Here is a snip of my configuration.py file that gets imported by each servlet

datapool = DBPool(PgSQL, 1, '192.168.0.10::comsci:user:pass')
clientpool={}
clientpool['metrony']=DBPool(PgSQL, 2, '192.168.0.10::metrony:user:pass')

And then to use any connection I call it like:

from configuration import datapool,clientpool

#
#  This is a big ugly class to handle all of the database interaction.
# It will get better

def summaryStats(user):
  summary={}
  conn=clientpool[user.company].getConnection()
  c=conn.cursor()
  c.execute("Select numrows from numrows")
  r=c.fetchone()
  summary['numrows'] = r.numrows
  return summary

So I create a dictionary of DB connections and use the company name as the key.

Now if I could only close the connections cleanly.......

-Aaron

----- Original Message ----- 
From: "Aleksandar Kacanski" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, November 12, 2001 11:57 AM
Subject: [Webware-discuss] approach to db connection pooling


> Any new developments on the db connection
> pooling?
> I have been trying for couple of days
> (unsuccessfully) to make some sort of 
> session caching, attaching db object to the
> Application object or Cans approach.
> Does anyone has any examples of how this might be
> implemented. I am interested in getting several
> connections open at the startup of the App, and
> passing the object to servlets.
> any suggestions?
> 
> __________________________________________________
> Do You Yahoo!?
> Find a job, post your resume.
> http://careers.yahoo.com
> 
> _______________________________________________
> Webware-discuss mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/webware-discuss



_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to