Changeset 838

Show
Ignore:
Timestamp:
03/12/07 20:34:49 (1 year ago)
Author:
mfenniak
Message:

Add some checks to DBAPI methods.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pg8000/trunk/pg8000.py

    r836 r838  
    8585    Error = Error 
    8686    InterfaceError = InterfaceError 
     87    InternalError = InternalError 
    8788    DatabaseError = DatabaseError 
    8889    DataError = DataError 
     
    273274            self.arraysize = 1 
    274275 
     276        rowcount = property(lambda self: self._getRowCount()) 
     277        def _getRowCount(self): 
     278            return -1 
     279 
     280        description = property(lambda self: self._getDescription()) 
     281        def _getDescription(self): 
     282            return None 
     283 
    275284        def execute(self, operation, args=()): 
     285            if self.cursor == None: 
     286                raise InterfaceError("cursor is closed") 
    276287            new_query, new_args = DBAPI.convert_paramstyle(DBAPI.paramstyle, operation, args) 
    277288            self.cursor.execute(new_query, *new_args) 
     
    282293 
    283294        def fetchone(self): 
     295            if self.cursor == None: 
     296                raise InterfaceError("cursor is closed") 
    284297            return self.cursor.read_tuple() 
    285298 
     
    293306 
    294307        def fetchall(self): 
     308            if self.cursor == None: 
     309                raise InterfaceError("cursor is closed") 
    295310            return tuple(self.cursor.iterate_tuple()) 
    296311 
     
    321336            # statements on other threads.  Support for that type of lock will 
    322337            # be done later. 
     338            if self.conn == None: 
     339                raise InterfaceError("connection is closed") 
    323340            self.conn.commit() 
    324341            self.conn.begin() 
     
    326343        def rollback(self): 
    327344            # see bug description in commit. 
     345            if self.conn == None: 
     346                raise InterfaceError("connection is closed") 
    328347            self.conn.rollback() 
    329348            self.conn.begin() 
     
    14521471    py_types = { 
    14531472        int: {"tid": 1700, "txt_out": numeric_out}, 
     1473        long: {"tid": 1700, "txt_out": numeric_out}, 
    14541474        str: {"tid": 25, "txt_out": textout}, 
    14551475        unicode: {"tid": 25, "txt_out": textout}, 
     
    14661486        23: {"txt_in": int4in, "bin_in": int4recv, "prefer": "bin"}, 
    14671487        25: {"txt_in": varcharin}, # TEXT type 
     1488        26: {"txt_in": numeric_in}, # oid type 
    14681489        700: {"txt_in": float4in, "bin_in": float4recv, "prefer": "bin"}, 
    14691490        701: {"txt_in": float8in, "bin_in": float8recv, "prefer": "bin"},