Thanks Jonathan,

>>Your question and example are both a bit confusing
Yes-as I mentioned in my post, and I am new to databases and SQL,so I don't 
know how to ask for what I'm looking for.

After creating the relationship that you mentioned, my queries now pull the 
data from the referenced tables.



On Thursday, June 11, 2015 at 10:47:17 AM UTC-7, Jonathan Vanasco wrote:
>
> Your question and example are both a bit confusing.  I'll try to impart 
> some knowledge that can help you re-focus an ask.
>
> 1. In your example, `Session.query(CaseTestInstance)` will return all the 
> data in the `cases_test_instance` table.
> 2. "Recursive Queries" can mean a few things (and is often used with 
> Contextual Table Expressions or functions that use the `with recursive` 
> operator), and are usually a bit of an advanced topic.  I think you mean 
> something else.
> 3. It sounds like you want to load associated or related data to the 
> foreign keys.  In your example, I you would need to create classes that 
> reflect the tables 'cases_test`, `auth_user` and `slaves_groups`.  In 
> SqlAlchemy to get this data you must define the classes/tables and then set 
> a `relationship` (and optionally a backref, so the relationship is 
> accessible from both objects).  You can then automatically load the 
> relationship with one of the many techniques, or use a table join.
>
> The ForeignKey merely states that the column in your table should/must 
> correspond to the column in the other table.  It implies that there is a 
> relationship, but you must explicitly declare the relationship in your 
> code.  a column like `slave_group_id` would usually be paired with a 
> relationship called `slave_group`.  
>
> advanced db designs might have multiple declared relationships that are 
> built off the ForeignKey used in conjunction with multiple modifiers.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to