/[papo]/gnue/common/src/dbdrivers/_pgsql/DBdriver.py
ViewVC logotype

Diff of /gnue/common/src/dbdrivers/_pgsql/DBdriver.py

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

revision 1.14 by styxman, Sat Nov 16 00:19:32 2002 UTC revision 1.14.2.1 by anthonyl, Tue Mar 4 22:09:34 2003 UTC
# Line 16  Line 16 
16  # write to the Free Software Foundation, Inc., 59 Temple Place  # write to the Free Software Foundation, Inc., 59 Temple Place
17  # - Suite 330, Boston, MA 02111-1307, USA.  # - Suite 330, Boston, MA 02111-1307, USA.
18  #  #
19  # Copyright 2000-2002 Free Software Foundation  # Copyright 2000-2003 Free Software Foundation
20  #  #
21  # FILE:  # FILE:
22  # _pgsql/DBdriver.py  # _pgsql/DBdriver.py
# Line 33  from string import lower, join, split Line 33  from string import lower, join, split
33  import sys  import sys
34  from gnue.common import GDebug, GDataObjects  from gnue.common import GDebug, GDataObjects
35  from gnue.common.dbdrivers._dbsig.DBdriver \  from gnue.common.dbdrivers._dbsig.DBdriver \
36     import DBSIG_RecordSet, DBSIG_ResultSet, DBSIG_DataObject     import DBSIG_RecordSet, DBSIG_ResultSet, DBSIG_DataObject, DBSIG_DataObject_Object
37    
38  from gnue.common.dbdrivers._dbsig.DBdriver import DBSIG_DataObject_Object as PGSQL_DataObject_Object  #from gnue.common.dbdrivers._dbsig.DBdriver import DBSIG_DataObject_Object as PGSQL_DataObject_Object
39  from gnue.common.dbdrivers._dbsig.DBdriver import DBSIG_DataObject_SQL as PGSQL_DataObject_SQL  from gnue.common.dbdrivers._dbsig.DBdriver import DBSIG_DataObject_SQL as PGSQL_DataObject_SQL
40    
41    
# Line 153  class PGSQL_DataObject(DBSIG_DataObject) Line 153  class PGSQL_DataObject(DBSIG_DataObject)
153          except:          except:
154            pass            pass
155    
156        if encoding!="":        if encoding.upper() not in ("",'DEFAULT'):
157          GDebug.printMesg(1,'Setting postgresql client_encoding to %s' % encoding)          GDebug.printMesg(1,'Setting postgresql client_encoding to %s' % encoding)
158          cursor = self._dataConnection.cursor()          cursor = self._dataConnection.cursor()
159          cursor.execute("SET CLIENT_ENCODING TO '%s'" % encoding)          cursor.execute("SET CLIENT_ENCODING TO '%s'" % encoding)
# Line 307  class PGSQL_DataObject(DBSIG_DataObject) Line 307  class PGSQL_DataObject(DBSIG_DataObject)
307      return list      return list
308    
309  class PGSQL_DataObject_Object(PGSQL_DataObject, \  class PGSQL_DataObject_Object(PGSQL_DataObject, \
310        PGSQL_DataObject_Object):        DBSIG_DataObject_Object):
311    
312    def __init__(self):    def __init__(self):
313      PGSQL_DataObject.__init__(self)      PGSQL_DataObject.__init__(self)
# Line 360  class PGSQL_DataObject_Object(PGSQL_Data Line 360  class PGSQL_DataObject_Object(PGSQL_Data
360          cursor.close()          cursor.close()
361          self._primaryKeys[table] = fields          self._primaryKeys[table] = fields
362    
363      
364  #  #
365  #  Extensions to Trigger Namespaces  #  Extensions to Trigger Namespaces
366  #  #
# Line 376  class PGSQL_TriggerExtensions: Line 377  class PGSQL_TriggerExtensions:
377    def getSequence(self, name):    def getSequence(self, name):
378      return self.__singleQuery("select nextval('%s')" % name)      return self.__singleQuery("select nextval('%s')" % name)
379    
380    
381    def atomicModify(self, func, field, dataObject, record, cond=None):    def atomicModify(self, func, field, dataObject, record, cond=None):
382        print "in atomic Modify"
383      if string.count(dataObject.table,',') == 0:      if string.count(dataObject.table,',') == 0:
384        table = dataObject.table        table = dataObject.table
385      elif field.count('.'):      elif field.count('.'):
# Line 417  class PGSQL_TriggerExtensions: Line 420  class PGSQL_TriggerExtensions:
420      getValueStmt = "BEGIN; SELECT %s FROM %s WHERE %s FOR UPDATE; " % \      getValueStmt = "BEGIN; SELECT %s FROM %s WHERE %s FOR UPDATE; " % \
421                     (field, table, \                     (field, table, \
422                      string.join(where,' AND ') )                      string.join(where,' AND ') )
423        print getValueStmt
424    
425      try:      try:
426        cursor.execute(getValueStmt)        cursor.execute(getValueStmt)
# Line 454  class PGSQL_TriggerExtensions: Line 458  class PGSQL_TriggerExtensions:
458      updateStmt = "UPDATE %s SET %s WHERE %s" % \      updateStmt = "UPDATE %s SET %s WHERE %s" % \
459                   (table, " %s = %s " % (auxField, str(value)), \                   (table, " %s = %s " % (auxField, str(value)), \
460                    string.join(where,' AND ') ) + "; COMMIT"                    string.join(where,' AND ') ) + "; COMMIT"
461        print updateStmt
462      try:      try:
463        cursor.execute(updateStmt)        cursor.execute(updateStmt)
464        cursor.close()        cursor.close()

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.14.2.1

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