Skip to content

Instantly share code, notes, and snippets.

@mthri
Created September 24, 2024 11:48
Show Gist options
  • Save mthri/03d3e92741c4fc8e6516871ac38e852b to your computer and use it in GitHub Desktop.
Save mthri/03d3e92741c4fc8e6516871ac38e852b to your computer and use it in GitHub Desktop.
print sql query in django
import os
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
},
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': os.path.join(BASE_DIR, 'sql_queries.log'), # Log to a file
},
},
'loggers': {
'django.db.backends': {
'level': 'DEBUG',
'handlers': ['console', 'file'], # Log to console and file
},
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment