Skip to content

Instantly share code, notes, and snippets.

@matanper
Created March 12, 2025 11:29
Show Gist options
  • Save matanper/a0ae89e2a80794f4ec8e3c3213ed6d06 to your computer and use it in GitHub Desktop.
Save matanper/a0ae89e2a80794f4ec8e3c3213ed6d06 to your computer and use it in GitHub Desktop.
FastAPI sqlalchemy profiler
@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