Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6705039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:21:28+00:00 2026-05-26T07:21:28+00:00

Django logs SQL operations to an internal buffer (whether logging to file or not)

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T07:21:29+00:00Added an answer on May 26, 2026 at 7:21 am

    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:

    from django.conf import settings
    from django.db.backends.base.base import BaseDatabaseWrapper
    from django.db.backends.utils import CursorWrapper
    
    if settings.DEBUG:
        BaseDatabaseWrapper.make_debug_cursor = lambda self, cursor: CursorWrapper(cursor, self)
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Django application that logs users in and out using the standard
(Django 1.x, Python 2.6.x) I have models to the tune of: class Animal(models.Model): pass
django's manager docs has a paragraph overwritten with DO NOT FILTER AWAY ANY RESULTS
I'm working on an intranet django project (not using GAE) for a company that
I'm trying to configure logging for a Django app using the Python logging module.
When a user logs in to a Django app, how do I change the
I'm using Django with FastCGI + nginx. Where are the logs (errors) stored in
I can load the fixture file in my django application by using loaddata: manage.py
Background I have a custom authentication back end for our django applications that refers
I'm running Django 1.3, using Sessions Middleware and Auth Middleware: # settings.py SESSION_ENGINE =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.