the best way would be that your database uses FOREIGN KEY constraints,  
which would be reflected.  If your tables don't have any, you can  
express the ForeignKey construct post-reflection as described in 
http://www.sqlalchemy.org/docs/05/metadata.html#overriding-reflected-columns 
  .

as far as the ORM is concerned, you have to use relation() explicitly  
or use one of the "automatic" recipes out there, like autocode.


On Apr 23, 2009, at 11:07 AM, greg wrote:

>
> Hello,
>
> How do I create a link between two tables (1:1) when using reflection
> to define my objects?  Suppose my database has tables:
>
> Table_A
> id (Integer, primary_key)
> name (String)
>
> Table_B
> id (Integer, primary_key)
> shoe_size (VarChar(5))
>
> In my program I do:
>
> A = Table('Table_A', metadate, engine, autoload_with=engine)
> B = Table('Table_B', metadate, engine, autoload_with=engine)
>
> Now, how do I go about creating a link, say A_id, from table 'B' to
> table 'A.id'
>
> Thanks for your help!
> --greg
>
> >


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

Reply via email to