Re: table.column in cursor.description?
Karsten Hilbert <[email protected]>
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Jul 23, 2009 at 03:18:27PM +0800, James Henstridge wrote:
> >>>> cursor.execute("select * from document, element")
> >>>> print cursor.description
> > [('document.id', ...), ('document.name', ...), ('element.id', ...), ('element.text', ...)]
> >
> > ...instead of the current behaviour, which is:
> >
> >>>> print cursor.description
> > [('id', ...), ('name', ...), ('id', ...), ('text', ...)]
>
> The column names for result sets come directly from PostgreSQL.
> Psycopg2 isn't adding or removing any information here. I don't know
> if it is possible to change PostgreSQL's behaviour here, but if you
> can it is likely that the change would be reflected in Psycopg2 with
> no extra effort.
Sure :-)
select a as "foo.a", b as "foo.b" from foo;
That probably isn't what the OP wanted, though.
One could also define a view
create view qualified_foo as
select
foo.a as "foo.a",
foo.b as "foo.b"
from foo
;
and select from that.
Karsten
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346