返回介绍

Recording Query Information

发布于 2023-05-20 01:15:15 字数 1515 浏览 0 评论 0 收藏 0

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文