开发者

Monitor database requests in Django, tied to line number

We've got some really strange extraneous DB hits happening in our project. Is there any way to monitor where the requests are coming from, possibly by line number? The SQL printing middleware helps, but we've looked everywhere those kinds of requests 开发者_如何学Cmight be generated and can't find the source.

If the above isn't possible, any pointers on narrowing down the source would be greatly appreciated.


To find the code executing queries, you can install django-debug-toolbar to figure out what commands are being executed and which tables they're operating on.

Once you've done that, try hooking into the appropriate Django signals for those models and using print and assert to narrow the code.

I'm sure there's a better way to do some of this (a python debugger?) but this is the first thing that comes to mind and probably what I would end up doing myself.


if you want track SQL queries for performance optimization and debug purpose and how to monitor query call in Django for that this blog will help you out

Tracking SQL Queries for a Request using Django

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜