commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/common/src/dbdrivers/odbc DBdriver.py


From: Jason Cater
Subject: gnue/common/src/dbdrivers/odbc DBdriver.py
Date: Tue, 29 Jan 2002 15:23:09 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/01/29 15:23:09

Modified files:
        common/src/dbdrivers/odbc: DBdriver.py 

Log message:
        added strict counts to odbc

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/dbdrivers/odbc/DBdriver.py.diff?tr1=1.12&tr2=1.13&r1=text&r2=text

Patches:
Index: gnue/common/src/dbdrivers/odbc/DBdriver.py
diff -c gnue/common/src/dbdrivers/odbc/DBdriver.py:1.12 
gnue/common/src/dbdrivers/odbc/DBdriver.py:1.13
*** gnue/common/src/dbdrivers/odbc/DBdriver.py:1.12     Tue Jan 29 14:54:42 2002
--- gnue/common/src/dbdrivers/odbc/DBdriver.py  Tue Jan 29 15:23:09 2002
***************
*** 239,254 ****
         'between':         (3,   3, '%s BETWEEN %s AND %s',   None     ) }
  
    def __init__(self):
!     GDataObjects.DataObject.__init__(self)
  
      GDebug.printMesg (1,"DB-SIG database driver backend initializing")
  
      self._resultSetClass = ODBC_ResultSet
      self._DatabaseError = None
  
  
    # This should be over-ridden only if driver needs more than user/pass
!   def getLoginFields(self): 
      return [['_username', 'User Name',0],['_password', 'Password',1]]
  
  
--- 239,255 ----
         'between':         (3,   3, '%s BETWEEN %s AND %s',   None     ) }
  
    def __init__(self):
!     GDataObjects.DataObject.__init__(self, strictQueryCount=1)
  
      GDebug.printMesg (1,"DB-SIG database driver backend initializing")
  
      self._resultSetClass = ODBC_ResultSet
      self._DatabaseError = None
+     self._strictQueryCount = strictQueryCount
  
  
    # This should be over-ridden only if driver needs more than user/pass
!   def getLoginFields(self):
      return [['_username', 'User Name',0],['_password', 'Password',1]]
  
  
***************
*** 259,265 ****
  
      try:
        self._dataConnection = odbc.odbc( "%s/%s/%s" % (
!                    connectData['service'], 
                     connectData['_username'], 
                     connectData['_password']))
  
--- 260,266 ----
  
      try:
        self._dataConnection = odbc.odbc( "%s/%s/%s" % (
!                    connectData['service'],
                     connectData['_username'], 
                     connectData['_password']))
  
***************
*** 290,309 ****
    def _postConnect(self):
      self.triggerExtensions = TriggerExtensions(self._dataConnection)
  
!   def _createResultSet(self, conditions={}, readOnly=0, 
masterRecordSet=None): 
!     try: 
        cursor = self._dataConnection.cursor()
        cursor.execute(self._buildQuery(conditions))
  
!     except self._DatabaseError, err: 
        raise GDataObjects.ConnectionError, err
      rs = self._resultSetClass(self, cursor=cursor, 
masterRecordSet=masterRecordSet)
!     if readOnly: 
        rs._readonly = readOnly
      return rs
  
  
!   def commit(self): 
      GDebug.printMesg (5,"DB-SIG database driver: commit()")
  
      try: 
--- 291,330 ----
    def _postConnect(self):
      self.triggerExtensions = TriggerExtensions(self._dataConnection)
  
!   def _createResultSet(self, conditions={}, readOnly=0, masterRecordSet=None):
!     try:
        cursor = self._dataConnection.cursor()
        cursor.execute(self._buildQuery(conditions))
  
!     except self._DatabaseError, err:
        raise GDataObjects.ConnectionError, err
      rs = self._resultSetClass(self, cursor=cursor, 
masterRecordSet=masterRecordSet)
! 
!     # pull a record count for the upcomming query
!     if self._strictQueryCount:
!       rs._recordCount = self._getQueryCount(conditions)
! 
!     if readOnly:
        rs._readonly = readOnly
      return rs
  
  
!   def _getQueryCount(self,conditions={}):
!     cursor = self._dataConnection.cursor()
! 
!     cursor.execute(self._buildQueryCount(conditions))
!     rs = cursor.fetchone()
!     return int(rs[0])
! 
!     
!   def _buildQueryCount(self, conditions={}):
!     q = "SELECT count(*) FROM %s%s" % (self.table, 
self._conditionToSQL(conditions))
! 
!     GDebug.printMesg(5,q)
! 
!     return q
! 
!   def commit(self):
      GDebug.printMesg (5,"DB-SIG database driver: commit()")
  
      try: 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]