On Fri, Jun 22, 2007 at 04:40:58PM -0000, Michael Bayer wrote:
> On Jun 22, 12:12 pm, Christoph Haas <[EMAIL PROTECTED]> wrote:
> > 2007-06-22 18:09:57,852 INFO sqlalchemy.engine.base.Engine.0x..6c SELECT
> > records_a.id, records_a.domain_id, records_a.dhcpzone_id, records_a.name,
> > records_a.type, records_a.content, records_a.ttl, records_a.prio,
> > records_a.change_date, records_a.mac_address, records_a.inet
> > FROM records AS records_a LEFT OUTER JOIN records AS records_ptr ON
> > records_a.inet = records_ptr.inet AND records_ptr.type =
> > %(records_ptr_type)s
> > WHERE records_a.type = %(records_a_type)s
> > 2007-06-22 18:09:57,852 INFO sqlalchemy.engine.base.Engine.0x..6c
> > {'records_a_type': 'A', 'records_ptr_type': 'PTR'}
> >
> > In [5]: result.keys()
> > Out[5]:
> > ['id',
> > 'domain_id',
> > 'dhcpzone_id',
> > 'name',
> > 'type',
> > 'content',
> > 'ttl',
> > 'prio',
> > 'change_date',
> > 'mac_address',
> > 'inet']
> >
> > As you see the keys are just there once. Although the actual SQL result
> > contains these columns for both records_a and the joined records_ptr.
>
> set use_labels=True in your select() statement. the point of that is
> to combine table or alias names with column names as labels for all
> selected columns, so that names are automatically unique. the column-
> targeting i mentioned also would rely upon this to differentiate
> between the two tables.
Thank you. It's a tiny bit closer. However that still only gives the
left side of the join as results:
result=records_a.select(
records_a.c.type=='A',
from_obj=[model.outerjoin(records_a, records_ptr,
( (records_a.c.inet==records_ptr.c.inet) & (records_ptr.c.type=='PTR')
))],
use_labels=True).execute().fetchone()
In [9]: result
Out[9]: (108914, 1, None, u'foo.domain.tld', u'A', u'192.168.26.39', 86400, 0,
None, None, '192.168.26.39')
In [10]: result.keys()
Out[10]:
['records_a_id',
'records_a_domain_id',
'records_a_dhcpzone_id',
'records_a_name',
'records_a_type',
'records_a_content',
'records_a_ttl',
'records_a_prio',
'records_a_change_date',
'records_a_mac_address',
'records_a_inet']
Sorry for being a pain. But I'm kind of stuck here.
Christoph
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---