I am working with a fairly large MySQL database via the SQLAlchemy library, and I'd love to turn off MySQL's query caching to debug performance issues on a per-session basis. It's difficult to debug slow queries when repeating them results in much faster execution. With the CLI MySQL client, I can execute SET SESSION query_cache_type = OFF;
to achieve the result I'm looking for, and I would like to run this on every SQLAlchemy session (when I'm debugging).
But I can't figure out how to configure SQLAlchemy such that it runs SET SESSION query_cache_type = OFF
when it instantiates a new database session.
I've looked at the Engine and Connection docs, but can't seem to find anything.
Is there something obvious that I'm missing, or a better way of doing this?