Django logs SQL operations to an internal buffer (whether logging to file or not) when settings.DEBUG=True. Because I have long-running process that does a lot of DB operations, this causes my development-mode instances of the program to grow in memory consumption very quickly.
I would like to disable the internal SQL logging mechanism while leaving settings.DEBUG turned on for my development: is this possible?
Django version 1.3.0.
When settings.DEBUG is True, Django uses CursorDebugWrapper instead of CursorWrapper. This is what appends the queries to connection.queries and consumes memory. I would monkey-patch the connection wrapper to always use CursorWrapper:
Place this in some file that gets imported early in your application.
Disabling logging like others suggest won’t fix the problem, because CursorDebugWrapper still stores the queries in connection.queries even if logging is off.