# 1.导入模块:
from sqlalchemy.dialects import postgresql
# 2.给定ORM Query对象时,为了获得该ClauseElement.compile()方法,需要statement首先访问访问者:
statement = query.statement
# 3.使用literal_binds标志,传递给compile_kwargs来获取参数:
logging.info(‘statement====%s’,statement.compile(compile_kwargs={“literal_binds”:True}))
# 4.官网文档连接:http://docs.sqlalchemy.org/en/latest/faq/sqlexpressions.html
# 例如:
###################################
from sqlalchemy.dialects import postgresql
res = qury.statement
logging.info('sql == == %s', res.compile(compile_kwargs={"literal_binds": True}))
###################################