I'm have the 'type' column in the press_routing_press linking table;
something like this:

 

Sess.query(Press,
PressRoutingPress.type).join(Press.routes).filter(PressRouting.code=='A'
).all()

 

I've tried some variations of this, but no luck. I've also tried
applying what the documentation says about using the Association Object,
but haven't figured it out yet. I've gotten back lots of data, just not
the limited set I'm looking fore.

 

Thanks,

Doug

 

From: sqlalchemy@googlegroups.com [mailto:[EMAIL PROTECTED]
On Behalf Of Michael Bayer
Sent: Friday, September 26, 2008 4:10 PM
To: sqlalchemy@googlegroups.com
Subject: [sqlalchemy] Re: How to perform inner joins

 

 

 

sess.query(Press,
PressRouting.code).join(Press.routes).filter(PressRouting.code=='A').all
()

 

will return tuples in the form:

 

(some Press object, "somecode")

 

 

On Sep 26, 2008, at 3:25 PM, Doug Farrell wrote:





Michael,

 

You're right of course, your version works fine. I cut and pasted what
you have into my code framework, cleaned up some stuff and it works
there as well. One thing I cleaned up was this:

 

# initialize the mysql engine and SqlAlchemy base objects

engine = create_engine(__config__.database.workflow_url, echo=True)

metadata = MetaData(engine)

 

Rather than what you did, which was to create the metatdata = MetaData()
first and then bind it to the engine after the mapping with this:
metadata.create_all(engine). I don't know if that made the difference or
not.

 

To impose on your further, how can I get the 'type' field that is
defined as a column in the press_routing_press linking table that goes
with everyting that comes back with PressRouting.code=='A' ?

 

Again, thanks for your help and patience, I've been using Python for
awhile, but I'm a DB novice...

Doug

 

 

From: sqlalchemy@googlegroups.com [mailto:[EMAIL PROTECTED]
On Behalf Of Michael Bayer
Sent: Friday, September 26, 2008 3:07 PM
To: sqlalchemy@googlegroups.com
Subject: [sqlalchemy] Re: How to perform inner joins

 

Doug -

 

what happened with the example I pasted ?  It generates the exact SQL
you describe.   A full script is attached, using the mappings you've
sent.  It uses sqlite, so you can just run it.

 





 



 


--~--~---------~--~----~------------~-------~--~----~
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