[PyGreSQL] Using get() on views
Christoph Zwerschke
cito at online.de
Tue Nov 22 11:03:31 EST 2005
D'Arcy J.M. Cain wrote:
> Does anyone see any issue with the following change to allow pg.py to
> get() from a view?
I think the basic idea to allow get_attnames() and thus get() from views
is a good one.
However, you are tweaking the get_tables() method here to return not
only tables, but also views. I wouldn't do that because I expect
get_tables() returns only the "normal" tables to me.
Ad hoc I would suggest the following instead:
Add another method
get_relations(type=None)
which will return all kind of relations, including views, sequences and
indexes if no type is given, and if you pass the characters r, i, S, v,
c, s, t in type (or a combination of them, like 'tv'), then only the
relations of the corresponding type will be returned.
Then, in "get_attnames" you could change the line
if qcl not in self.get_tables():
to
if qcl not in self.get_relations('tv'):
Another idea would be to leave out this check in get_attnames
completely, because it can be simply included in the WHERE condition in
the following query that requests the attributes.
-- Christoph
More information about the PyGreSQL
mailing list