中文文档 v?
英文文档 v3.x
Recording Query Information
Warning
This feature is intended for debugging only.
Flask-SQLAlchemy can record some information about every query that executes during a request. This information can then be retrieved to aid in debugging performance. For example, it can reveal that a relationship performed too many individual selects, or reveal a query that took a long time.
To enable this feature, set SQLALCHEMY_RECORD_QUERIES
to True
in the Flask app config. Use get_recorded_queries()
to get a list of query info objects. Each object has the following attributes:
statement
The string of SQL generated by SQLAlchemy with parameter placeholders.
parameters
The parameters sent with the SQL statement.
start_time
/end_time
Timing info about when the query started execution and when the results where returned. Accuracy and value depends on the operating system.
duration
The time the query took in seconds.
location
A string description of where in your application code the query was executed. This may be unknown in certain cases.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论