> Doesn't that limit you to a single ConnectionPool?  What
> if you want
> multiple pools for different databases?

Here's how I do it (similar to a few other folks):

module (DatabaseWrap) which holds the connectionpools and
provides a few simplified query functions.

module level dictionary called _stores keyed by DSN.

DatabaseWrap.getConn(dsn) returns a connection for a
specific database name, by locking and then checking for
the name in _stores. if it doesn't exist, it creates a new
DBPool in _stores.

    def getConn(self, DSN):
        self.lock()
        dbpool = _stores.get(DSN, None)
        if dbpool is None:
            _stores[DSN] = DBPool(....)
            dbpool = _stores[DSN]
        self.unlock()
        return dbpool.getConnection()

This could easily be changed to map a databasename to a
group of connection parameters for python DBI syntax, as
opposed to using DSNs. (through a configurable file.)

Luke

=====
------------------
Sanity is a form of conformity.
  -John Nash
------------------

__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to