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

Diff of /gnue-common/src/datasources/drivers/mysql/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:20 2003 UTC revision 1.1.2.2 by jcater, Wed Nov 19 03:00:24 2003 UTC
# Line 70  class Introspection(GIntrospection.Intro Line 70  class Introspection(GIntrospection.Intro
70      # TODO: This excludes any system tables and views. Should it?      # TODO: This excludes any system tables and views. Should it?
71      statement = "SHOW TABLES"      statement = "SHOW TABLES"
72    
73      cursor = self.native.cursor()      cursor = self._connection.native.cursor()
74      cursor.execute(statement)      cursor.execute(statement)
75    
76      list = []      list = []
77      for rs in cursor.fetchall():      for rs in cursor.fetchall():
78        list.append(GDataObjects.Schema(attrs={'id':rs[0], 'name':rs[0],        list.append(GIntrospection.Schema(attrs={'id':rs[0], 'name':rs[0],
79                           'type':'table',                           'type':'table',
80                           'primarykey': self.__getPrimaryKey(rs[0])},                           'primarykey': self.__getPrimaryKey(rs[0])},
81                           getChildSchema=self.__getFieldSchema))                           getChildSchema=self.__getFieldSchema))
# Line 88  class Introspection(GIntrospection.Intro Line 88  class Introspection(GIntrospection.Intro
88    def getSchemaByName(self, name, type=None):    def getSchemaByName(self, name, type=None):
89      statement = "DESCRIBE %s" % (name)      statement = "DESCRIBE %s" % (name)
90    
91      cursor = self.native.cursor()      cursor = self._connection.native.cursor()
92      cursor.execute(statement)      cursor.execute(statement)
93    
94      rs = cursor.fetchone()      rs = cursor.fetchone()
95      if rs:      if rs:
96        schema = GDataObjects.Schema(attrs={'id':name, 'name':name,        schema = GIntrospection.Schema(attrs={'id':name, 'name':name,
97                             'type':'table',                             'type':'table',
98                             'primarykey': self.__getPrimaryKey(name,cursor)},                             'primarykey': self.__getPrimaryKey(name,cursor)},
99                             getChildSchema=self.__getFieldSchema)                             getChildSchema=self.__getFieldSchema)
# Line 107  class Introspection(GIntrospection.Intro Line 107  class Introspection(GIntrospection.Intro
107    def __getPrimaryKey(self, id, cursor=None):    def __getPrimaryKey(self, id, cursor=None):
108      statement = "DESCRIBE %s" % id      statement = "DESCRIBE %s" % id
109      if not cursor:      if not cursor:
110        cursor = self.native.cursor()        cursor = self._connection.native.cursor()
111        close_cursor = 1        close_cursor = 1
112      else:      else:
113        close_cursor = 0        close_cursor = 0
# Line 128  class Introspection(GIntrospection.Intro Line 128  class Introspection(GIntrospection.Intro
128    
129      statement = "DESCRIBE %s" % parent.id      statement = "DESCRIBE %s" % parent.id
130    
131      cursor = self.native.cursor()      cursor = self._connection.native.cursor()
132      cursor.execute(statement)      cursor.execute(statement)
133    
134      list = []      list = []
# Line 171  class Introspection(GIntrospection.Intro Line 171  class Introspection(GIntrospection.Intro
171          attrs['defaulttype'] = 'serial'          attrs['defaulttype'] = 'serial'
172    
173    
174        list.append(GDataObjects.Schema(attrs=attrs))        list.append(GIntrospection.Schema(attrs=attrs))
175    
176      cursor.close()      cursor.close()
177      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