/[gnue]/gnue-common/src/datasources/drivers/postgresql/Base/Connection.py
ViewVC logotype

Diff of /gnue-common/src/datasources/drivers/postgresql/Base/Connection.py

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

revision 1.1.2.1 by jcater, Fri Oct 10 01:21:26 2003 UTC revision 1.1.2.2 by siesel, Fri Oct 10 12:18:50 2003 UTC
# Line 54  class Connection(DBSIG2.Connection): Line 54  class Connection(DBSIG2.Connection):
54    _pg_connectString = 'host=%s dbname=%s user=%s password=%s port=%s'    _pg_connectString = 'host=%s dbname=%s user=%s password=%s port=%s'
55    _pg_driver = None    _pg_driver = None
56    
57      _pg_encTable={'ascii'     :  'SQL_ASCII',     # ASCII
58                    ''          :  'EUC_JP',        # Japanese EUC
59                    ''          :  'EUC_CN',        # Chinese EUC
60                    ''          :  'EUC_KR',        # Korean EUC
61                    ''          :  'JOHAB',         # Korean EUC (Hangle base)
62                    ''          :  'EUC_TW',        # Taiwan EUC
63                    'utf-8'     :  'UNICODE',       # Unicode (UTF-8)
64                    ''          :  'MULE_INTERNAL', # Mule internal code
65                    'iso8859-1' :  'LATIN1',        # ISO 8859-1 ECMA-94 Latin Alphabet No.1
66                    'iso8859-2' :  'LATIN2',        # ISO 8859-2 ECMA-94 Latin Alphabet No.2
67                    'iso8859-3' :  'LATIN3',        # ISO 8859-3 ECMA-94 Latin Alphabet No.3
68                    'iso8859-4' :  'LATIN4',        # ISO 8859-4 ECMA-94 Latin Alphabet No.4
69                    'iso8859-9' :  'LATIN5',        # ISO 8859-9 ECMA-128 Latin Alphabet No.5
70                    'iso8859-10':  'LATIN6',        # ISO 8859-10 ECMA-144 Latin Alphabet No.6
71                    'iso8859-13':  'LATIN7',        # ISO 8859-13 Latin Alphabet No.7
72                    'iso8859-14':  'LATIN8',        # ISO 8859-14 Latin Alphabet No.8
73                    'iso8859-15':  'LATIN9',        # ISO 8859-15 Latin Alphabet No.9
74                    'iso8859-16':  'LATIN10',       # ISO 8859-16 ASRO SR 14111 Latin Alphabet No.10
75                    'iso8859-5' :  'ISO-8859-5',    # ECMA-113 Latin/Cyrillic
76                    'iso8859-6' :  'ISO-8859-6',    # ECMA-114 Latin/Arabic
77                    'iso8859-7' :  'ISO-8859-7',    # ECMA-118 Latin/Greek
78                    'iso8859-8' :  'ISO-8859-8',    # ECMA-121 Latin/Hebrew
79                    ''          :  'KOI8',          # KOI8-R(U)
80                    ''          :  'WIN',           # Windows CP1251
81                    ''          :  'ALT',           # Windows CP866
82                    ''          :  'WIN1256',       # Arabic Windows CP1256
83                    ''          :  'TCVN',          # Vietnamese TCVN-5712 (Windows CP1258)
84                    ''          :  'WIN874'}        # Thai Windows CP874
85    
86    def connect(self                                                                                                                                                                                                                                          , connectData={}):    def connect(self                                                                                                                                                                                                                                          , connectData={}):
87    
88      if not hasattr(self,'_DatabaseError'):      if not hasattr(self,'_DatabaseError'):
# Line 83  class Connection(DBSIG2.Connection): Line 112  class Connection(DBSIG2.Connection):
112        raise GDataObjects.LoginError, value        raise GDataObjects.LoginError, value
113    
114      try:      try:
       encoding = ""  
115        try:        try:
116          encoding = connectData['encoding']          self._encoding = connectData['encoding']
117          except KeyError:
118            pass
119    
120          try:
121            self._pg_encoding = self._pg_encTable[self._encoding]
122        except KeyError:        except KeyError:
123          # if encoding is not defined in connectData use gnue.conf setting instead          GDebug.printMesg(1,_("Encoding '%s' is not supported by postgresql dbdriver.") % \
124          try:                           self._encoding + _('Using default encoding.'))
125            encoding = gConfig('encoding')          self._pg_encoding = ''
126          except:          
127            pass        if self._pg_encoding not in ("",'DEFAULT'):
128            GDebug.printMesg(1,'Setting postgresql client_encoding to %s (%s)' % (self._pg_encoding,
129        if encoding.upper() not in ("",'DEFAULT'):                                                                                self._encoding))
130          GDebug.printMesg(1,'Setting postgresql client_encoding to %s' % encoding)          cursor = self._dataConnection.cursor()
131          cursor = self.native.cursor()          cursor.execute("SET CLIENT_ENCODING TO '%s'" % self._pg_encoding)
         cursor.execute("SET CLIENT_ENCODING TO '%s'" % encoding)  
132          cursor.close()          cursor.close()
133    
134      except self._DatabaseError:      except self._DatabaseError:

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