Answer the question
In order to leave comments, you need to log in
How to query 3 tables in Flask SQLAlchemy?
I am rewriting a site.
And there are quite a lot of this kind of queries to the MySQL database.
SELECT b.id,
DATE_FORMAT( b.date , " %d.%m.%Y " ) AS date,
b.item_name , c.desc_rus , a.email
FROM users a, user_item b, lang c
WHERE a.id = ?
AND a.id = b.user_id
AND c.code = b.dest_lang
ORDER BY b.date ASC
Answer the question
In order to leave comments, you need to log in
In general, it would be nice to see the structure, because. the links between the tables are not clear (is there fk there)
Well, if we assume that the query contains a link by fk, then something like this:
Then select the fields that you need.
Second option:
If fk is not specified, then, for example, use add_entity.
It is very difficult to reason here, without knowing how the tables in the database are described, how the models are described in SQLA (go there, it can reflect at all), what kind of load, and so on.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question