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)) |
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) |
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 |
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 = [] |
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 |