I have a file MyDataPool.py
 
from MiscUtils.DBPool import DBPool
from pyPgSQL import PgSQL
dbpool = DBPool(PgSQL, 10, 'localhost::foo:user1:')
 
Then in all my python code and servlets
I find myself constantly doing
 
conn = dbpool.getConnection
c = conn.cursor()
c.execute(QUERY)
c.close
conn.commit
conn.close()
 
So in MyDataPool I defined a class
 
def query(s):
   conn = dbpool.getConnection
   c = conn.cursor()
   c.execute(s)
   c.close
   conn.commit
   conn.close()
 
so that I can just do
from MyDataPool import query
query(s)
 
for some reason this doesn't work, from my debug, I see that it gets called, but when I check the database, nothing is saved.  So how can I refactor all my calls to the DB?


The Opportunity Gap
 
Between what is and what could be exists a potential gap.
This gap is an opportunity gap; With every passing of time, it closes.
The gap becomes closed, when what was becomes what is,
... OR what was can no longer be what it could be.


Do you Yahoo!?
vote.yahoo.com - Register online to vote today!