Changeset 844 for trunk/pgdb.py


Ignore:
Timestamp:
Feb 8, 2016, 6:15:53 PM (4 years ago)
Author:
cito
Message:

New connection attribute "closed" in pgdb

This can be useful when implementing connection pools, e.g. in SQLAlchemy.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pgdb.py

    r843 r844  
    13421342            raise _op_error("Connection has been closed")
    13431343
     1344    @property
     1345    def closed(self):
     1346        """Check whether the connection has been closed or is broken."""
     1347        try:
     1348            return not self._cnx or self._cnx.status != 1
     1349        except TypeError:
     1350            return True
     1351
    13441352    def commit(self):
    13451353        """Commit any pending transaction to the database."""
Note: See TracChangeset for help on using the changeset viewer.