I have a sql like:
我有一个sql语句:
DBSession().query(Model).filter(***)
and I want to explain this sql using SQLAlchemy
.
我想用SQLAlchemy解释这个sql。
1 个解决方案
#1
4
Your filter call can be turned into a string:
您的过滤器调用可以转换为字符串:
query = str(DBSession().query(Model).filter(***))
You can then use that to ask for a MySQL explanation:
然后你可以用它来询问MySQL的解释:
DBSession().execute('EXPLAIN ' + query)
You may have to include any bound parameters the filters added to your query as a dictionary:
您可能必须包含过滤器作为字典添加到查询中的任何绑定参数:
DBSession().execute('EXPLAIN ' + query, {'param_1': 'value1', 'param_2': 'value2'})
#1
4
Your filter call can be turned into a string:
您的过滤器调用可以转换为字符串:
query = str(DBSession().query(Model).filter(***))
You can then use that to ask for a MySQL explanation:
然后你可以用它来询问MySQL的解释:
DBSession().execute('EXPLAIN ' + query)
You may have to include any bound parameters the filters added to your query as a dictionary:
您可能必须包含过滤器作为字典添加到查询中的任何绑定参数:
DBSession().execute('EXPLAIN ' + query, {'param_1': 'value1', 'param_2': 'value2'})