Let’s have 3 tables A, B, C and relations between them.
A is many to one with B
B is one to many with C
How to write relation in sqlalchemy to have access to C from A, like: A.C[0].some_column
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In your example
A is many to one with B
B is one to many with C
So finally
A is many to many C is the last relationship if you want to access the C from A.
You have to create the relationship in each model to access directly.
For example
then you can access by A.x.y which will return you the list.
To access like A.x you can use secondaryjoin you can give query which will be access direct C from A.
For example
This might be work for you.