On Jan 10, 2011, at 3:47 PM, Petra Clementson wrote:

> Okay, so I implemented "join(A, B).alias()", but I can't seem to access the 
> columns of the aliased table. Here is my code:
> 
> 
> session = sessionfactory()
> 
> combined_1 = join(DiskFile, Header).alias()
> combined_2 = join(DiskFile, Header).alias()
> 
> query = session.query(header).select_from(combined_1, 
> combined_2).filter(DiskFile.canonical == True).filter(Header.datalab != 
> 'none').filter(combined_1.datalab == combined_2.datalab)
> 
> 
> And I get:
> AttributeError: 'Alias' object has no attribute 'datalab'
> 
> 

When you work with join() and alias() objects, you start using the SQL 
expression language.  The objects are known as "selectables" and their 
namespace of column attributes is available via the .c. attribute.

It's advisable to get a feel for SQL expression constructs via the tutorial: 
http://www.sqlalchemy.org/docs/core/tutorial.html  .  You can probably skim the 
first half of it then start looking at the sections on "Aliases" and "Joins" 
more closely.   





-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to