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