Closed AndreasMietk closed 1 year ago
If you want to display SQLAlchemy queries, you must register the DB-engine as shown in the example below.
app/core/database.py
from sqlalchemy import create_engine
from debug_toolbar.panels.sqlalchemy import SQLAlchemyPanel
engine = create_engine(...) # Please set your settings
class SQLAlchemyPanel_(SQLAlchemyPanel):
async def process_request(self, request: Request) -> Response:
self.register(engine)
try:
return await super().process_request(request)
finally:
self.unregister(engine)
app/main.py
app = FastAPI(..., debug=True)
app.add_middleware(
DebugToolbarMiddleware,
panels=["core.database.SQLAlchemyPanel_"],
)
My repository below incorporates these. https://github.com/takashi-yoneya/fastapi-mybest-template/blob/master/app/core/database.py
Thanks @AndreasMietk for sharing this, the issue is fixed, see #22 and v0.3.0.
Thanks @AndreasMietk for sharing this, the issue is fixed, see #22 and v0.3.0.
I am facing the same problem as mention in title that is no sql were recorded during the calling the endpoint. I tried different method as mention but it didnot work. Seems like this issue hasnot been fixed.
Hi, im getting this error on the Versions Tab
And i am not able to get any SQL query response. I am using the Depends() function on my routes, Tried with sqllite and maria db with no success. The dependency injection setup is as the docs requsted.
The same results with starting via python3 form my machine or docker (python:3.10.3-alpine) :(
my requirements.txt