/[gnue]/gnue-common/src/datasources/drivers/postgresql/pypgsql/__init__.py
ViewVC logotype

Diff of /gnue-common/src/datasources/drivers/postgresql/pypgsql/__init__.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.2.1 by jcater, Fri Oct 10 01:21:29 2003 UTC revision 1.1.2.2 by jcater, Sat Nov 8 16:14:58 2003 UTC
# Line 28  Line 28 
28  # NOTES:  # NOTES:
29  #  #
30    
 __all__ = ('Connection')  
   
 import sys  
 from gnue.common.datasources import GDataObjects, GConditions, GConnections  
 from gnue.common.apps import GDebug  
 from gnue.common.datasources.drivers.postgresql.Base.Driver \  
    import PGSQL_RecordSet, PGSQL_ResultSet, PGSQL_DataObject, \  
           PGSQL_DataObject_SQL, PGSQL_DataObject_Object, \  
           PGSQL_TriggerExtensions  
   
 try:  
   from pyPgSQL import PgSQL # pyPgSQL 2.0 support  
 except ImportError:  
   import PgSQL              # pyPgSQL 1.6 support  
   
   
   
 class ResultSet(Base.ResultSet):  
   
   # TODO: Override the base _loadNextRecord as the fetchmany() from the cursor  
   # TODO: returns an exception instead of None.  Not sure wazzup with that.  
   def _loadNextRecord(self):  
     if self._cursor:  
       rs = None  
   
       try:  
         rsets = self._cursor.fetchmany()  
       except self._dataObject._DatabaseError, err:  
         rsets = None  
       except:  
         rsets = None  
   
       if rsets and len(rsets):  
         for rs in(rsets):  
           if rs:  
             i = 0  
             dict = {}  
             for f in (rs):  
               dict[self._fieldNames[i]] = f  
               i += 1  
             self._cachedRecords.append (self._recordSetClass(parent=self, \  
                                                              initialData=dict))  
           else:  
             return 0  
         return 1  
       else:  
         return 0  
     else:  
       return 0  
   
   
   
 class DataObject_Object(Base.DataObject_Object)  
   _resultSetClass = PG_ResultSet  
   
   
 class DataObject_SQL(Base.DataObject_SQL)  
   _resultSetClass = PG_ResultSet  
   
   
 class Connection(Base.Connection):  
   _pg_driver = PgSQL  
   _pg_connectString = '%s::%s:%s:%s::%s'  
   
   _supportedDataObjects = {  
     'object': DataObject_Object,  
     'sql':    DataObject_SQL  
   }  
   
   
   
31  __description__ = _("PyPGsql Data Driver for PostgreSQL")  __description__ = _("PyPGsql Data Driver for PostgreSQL")
32  __driverurl__ = "http://????"  __driverurl__ = "http://????"
33  __examples__ = ""  __examples__ = ""
34  __doc__ = ""  __doc__ = ""
35    
36    #
37    # Stub code to not initialize the Connection until needed.
38    # This greatly helps with error messages.
39    #
40    def Connection(*args, **parms):
41      from Driver import Connection as C
42      return C(*args, **parms)
43    

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26