Created
March 12, 2025 11:29
-
-
Save matanper/a0ae89e2a80794f4ec8e3c3213ed6d06 to your computer and use it in GitHub Desktop.
FastAPI sqlalchemy profiler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.middleware("http") | |
async def add_sql_tap(request: Request, call_next): | |
profiler = sqltap.start() | |
response = await call_next(request) | |
statistics = profiler.collect() | |
sqltap.report(statistics, "report.txt", report_format="text") | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment