Hi all,

Well, I'm still stumped by SqlAlchemy syntax, but it's getting better.
I've got some tables built this way using SqlAlchemy 0.5:

press_table = Table('press', metadata, autoload=True)
press_routing_table = Table('press_routing', metadata, autoload=True)
press_routing_press_table = Table('press_routing_press', 
                                  metadata,
                                  Column('press_id', 
                                         Integer, 
                                         ForeignKey('press.id'),
                                         primary_key=True),
                                  Column('press_routing_id',
                                         Integer,
                                         ForeignKey('press_routing.id'),
                                         primary_key=True),
                                  Column('type', MSEnum),
                                  autoload=True)
    
class Press(object): pass

class PressRouting(object): pass

mapper(Press, 
       press_table, 
       properties=dict(routes=relation(PressRouting, 
 
secondary=press_routing_press_table,
                                       backref='presses')))
       
mapper(PressRouting, press_routing_table)

I'm trying to represent a many-to-many relationship between the
press_table and the press_routing table using the linking table,
press_routing_press. I think I've got the table structure and mapping
set up, but now I need some help to build a query using SqlAlchemy that
does the same thing as this MySQL query:

select p.id, p.code
from press p
inner join press_routing_press prp
on p.id=prp.press_id
inner join press_routing pr
on pr.id=prp._press_routing_id
where pr.code='A'

This gives me the results I want from the MySQL command line against the
existing tables in the database, but I can't figure out how to construct
an equivalent SqlAlchemy version to do the same thing passing in 'A' as
the paramter.

I know I'm being dense about this, thanks in advance for the help,
Doug

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