flask-sqlalchemy-lite icon indicating copy to clipboard operation
flask-sqlalchemy-lite copied to clipboard

Implement SQLALCHEMY_RECORD_QUERIES

Open samuelhwilliams opened this issue 7 months ago • 1 comments

Provisionally opened to gauge whether this is something we'd be willing to bring in. If so I'll lift and apply tests as needed 👀 I would find this v useful though (will need an update to flask-debugtoolbar as well, which I'm happy to work on if this goes in).


Lifted verbatim from Flask-SQLAlchemy. Adding support for this will enable integration with Flask-DebugToolbar.

samuelhwilliams avatar May 15 '25 09:05 samuelhwilliams

Closing off; this was copied over to support flask-debugtoolbar which relies on this functionality in full-fledge flask-sqlalchemy.

I'll look at baking this all directly into flask-debugtoolbar.

samuelhwilliams avatar May 27 '25 17:05 samuelhwilliams

@davidism thanks for opening this again - I've added tests to the PR now, broadly in line with the test that Flask-SQLAlchemy has: https://github.com/pallets-eco/flask-sqlalchemy/blob/main/tests/test_record_queries.py. Is this still something you're willing to help get in?

samuelhwilliams avatar Jun 29 '25 20:06 samuelhwilliams

I will get to this eventually. I'm still not 100% sure on if or how I want to add it, so I'll need to find some time to review and play around with this.

davidism avatar Jul 16 '25 13:07 davidism

I've thought about this on and off over the past months. I'm concluding that it makes more sense to add this to Flask-DebugToolbar rather than here. There's nothing truly Flask-specific about this code, except for where it chooses to store the queries. It only seems to have a use case with Flask-DebugToolbar, other dashboards such as Sentry, OpenTelemetry, etc have their own monitoring integrations. Moving it to Flask-DebugToolbar would also allow you to support plain SQLAlchemy https://github.com/pallets-eco/flask-debugtoolbar/pull/110

davidism avatar Nov 06 '25 19:11 davidism