/[gnue]/gnue-common/src/datasources/drivers/postgresql/Schema/Discovery/Introspection.py
ViewVC logotype

Diff of /gnue-common/src/datasources/drivers/postgresql/Schema/Discovery/Introspection.py

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

revision 1.1.2.1 by jcater, Fri Oct 10 01:21:27 2003 UTC revision 1.1.2.2 by jcater, Wed Nov 19 03:00:25 2003 UTC
# Line 77  class Introspection(GIntrospection.Intro Line 77  class Introspection(GIntrospection.Intro
77              "and relname not like 'pg_%' " + \              "and relname not like 'pg_%' " + \
78              "order by relname"              "order by relname"
79    
80      cursor = self._dataConnection.cursor()      cursor = self._connection.native.cursor()
81      cursor.execute(statement)      cursor.execute(statement)
82    
83      list = []      list = []
84      for rs in cursor.fetchall():      for rs in cursor.fetchall():
85        list.append(GDataObjects.Schema(attrs={'id':rs[2], 'name':rs[0],        list.append(GIntrospection.Schema(attrs={'id':rs[2], 'name':rs[0],
86                           'type':rs[1] == 'v' and 'view' or 'table',                           'type':rs[1] == 'v' and 'view' or 'table',
87                           'primarykey': self.__getPrimaryKey(cursor, rs[2])},                           'primarykey': self.__getPrimaryKey(cursor, rs[2])},
88                           getChildSchema=self.__getFieldSchema))                           getChildSchema=self.__getFieldSchema))
# Line 97  class Introspection(GIntrospection.Intro Line 97  class Introspection(GIntrospection.Intro
97      statement = "select relname, relkind, oid from pg_class " + \      statement = "select relname, relkind, oid from pg_class " + \
98              "where relname = '%s'" % (name)              "where relname = '%s'" % (name)
99    
100      cursor = self._dataConnection.cursor()      cursor = self._connection.native.cursor()
101      cursor.execute(statement)      cursor.execute(statement)
102    
103      rs = cursor.fetchone()      rs = cursor.fetchone()
104      if rs:      if rs:
105        schema = GDataObjects.Schema(attrs={'id':rs[2], 'name':rs[0],        schema = GIntrospection.Schema(attrs={'id':rs[2], 'name':rs[0],
106                             'type':rs[1] == 'v' and 'view' or 'table',                             'type':rs[1] == 'v' and 'view' or 'table',
107                             'primarykey': self.__getPrimaryKey(cursor, rs[2]) },                             'primarykey': self.__getPrimaryKey(cursor, rs[2]) },
108                             getChildSchema=self.__getFieldSchema)                             getChildSchema=self.__getFieldSchema)
# Line 113  class Introspection(GIntrospection.Intro Line 113  class Introspection(GIntrospection.Intro
113      return schema      return schema
114    
115    def __getPrimaryKey(self, cursor, oid):    def __getPrimaryKey(self, cursor, oid):
116      cursor = self._dataConnection.cursor()      cursor = self._connection.native.cursor()
117      cursor.execute("select indkey from pg_index where indrelid=%s" % oid)      cursor.execute("select indkey from pg_index where indrelid=%s" % oid)
118      rs = cursor.fetchone()      rs = cursor.fetchone()
119      statement = "select attname from pg_attribute " \      statement = "select attname from pg_attribute " \
# Line 139  class Introspection(GIntrospection.Intro Line 139  class Introspection(GIntrospection.Intro
139              "pg_type.oid = atttypid and attnum >= 0" + \              "pg_type.oid = atttypid and attnum >= 0" + \
140              "order by attnum"              "order by attnum"
141    
142      cursor = self._dataConnection.cursor()      cursor = self._connection.native.cursor()
143      cursor.execute(statement)      cursor.execute(statement)
144    
145      list = []      list = []
# Line 180  class Introspection(GIntrospection.Intro Line 180  class Introspection(GIntrospection.Intro
180              attrs['defaulttype'] = 'constant'              attrs['defaulttype'] = 'constant'
181              attrs['defaultval'] = dflt              attrs['defaultval'] = dflt
182    
183        list.append(GDataObjects.Schema(attrs=attrs))        list.append(GIntrospection.Schema(attrs=attrs))
184    
185      cursor.close()      cursor.close()
186      return list      return list

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