I've cleaned up my Database module since last week and added auto
re-connects. I think it would be a good addition to DBPool.  Could
someone give it a look and see if it would be useful to add it to
Webware?

It solves the problems listed in the Vorbis thread and provides the
following benefits:

A DBPool for each database defined by simple names.
Automatically re-connects bad connections.
Provides access to connections, cursors or recordsets.
Automatic rollback when connections are created and re-used.
Records that provide:
  Traditional list lookup like PyDB-API: record[0].
  Case insensitive attribute lookup: record.firstName.
  Case insensitive dictionary lookup: record['firstName'].
  Automatic conversion of timestamps to mx.DateTime.DateTime objects.
  No back pointers to the database cursor/connection so they are freed
up.


Example:
class SitePage(Page,DataSourcePool):
  dataSources = {
    'myDsn': {'dbModule':pgdb, 'maxConnections':2,
              'connectString':'host:database:username:password'},
     }
        
  def writeContent(self):
    recordset = self.recordset("myDsn", "select firstName, lastName from
Account")
    for record in recordset:
      self.writeln('account name: %(firstName)s %(lastName)s<br>' %
record

Thanks,
Jeff

Database.py

Reply via email to