On Sep 4, 12:26 am, bukzor <[EMAIL PROTECTED]> wrote:
> I'm trying to optimize my number of connections by not fully
> initializing (read: not connecting) my connection until it's used in
> some way.

I had the same use case and I solved with a simple property. Here is
the code
I have for pymssql:

@property
def conn(self):
    if self._conn is None:
         self._conn = _mssql.connect(self.host, self.user,self.passwd)
 
self._conn.select_db(self.dbname)
    return self._conn

The connection is really instantiate only when you call self.conn to
perform the query, not when you instantiate the class.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to