On May 1, 2008, at 8:22 PM, Googli S wrote:

>
> Hello,
>
> I have two tables both of which have a userID in their primary key
> (one has composite primary key). There is no "valid table" for userID,
> i.e. there is no table (that I have access to) users which has a list
> of ALL userIDs.
>
> Now, I have records in both tables which have a userID which don't
> have a corresponding entry in the other table.
>
> I want to join these two tables and get only the records which have
> matching userIDs (i.e. ClassA.userID = ClassB.userID). Furthermore,
> since I want to pass this onto a PaginateDataGrid, I need these to be
> a dictionary.
>
> I tried this:
>
> ClassA
> .query
> .select_from(tableA.join(tableB,tableA.c.userID=tableB.c.userID))
>
> But that only returns items from ClassA. Where do I specify that I
> also want all the columns from ClassB?
>
> Thanks in advance.
> --

Just add_entity():

ClassA.query.add_entity(ClassB).select_from(<join>)

as far as the dictionary part you'd do some post processing on the  
results.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to