image.png
from flask import Flask from flask_sqlalchemy import SQLAlchemy from flask_debugtoolbar import DebugToolbarExtension
from config import SQLALCHEMY_DATABASE_URI, SQLALCHEMY_TRACK_MODIFICATIONS, SECRET_KEY
db = SQLAlchemy()
toolbar = DebugToolbarExtension()
def create_app(): app = Flask(name) app.debug = True app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = SQLALCHEMY_TRACK_MODIFICATIONS app.config['SECRET_KEY'] = 'TTC'
代码语言:javascript复制db.init_app(app=app)
toolbar.init_app(app)
return app
开启慢查询
SQLALCHEMY_RECORD_QUERIES=True
打印出慢查询的语句
image.png
image.png