Reputation: 632
We use Flask+SQLAlchemy in our web app. We found some slow sql queries in DB monitor. Is there any good way to find/locate the original SQLAlchemy queries according to generated sql? i.e. code mapping between ORM code and SQL code.
e.g. Add any unique token in generated sql comment, so we can find original ORM code by the token.
Upvotes: 0
Views: 79
Reputation: 15090
You can add sql comment with suffix_with
method
query = Table.query
query = query.suffix_with('-- %s' % query_token)
Upvotes: 1