Ddquery is a library built in python that add color in your SQL statements and show in your command shell (pretty), for relational databases that uses ORM of the Django
- Python ≥ 3.3
- Django ≥ 1.8
pip install ddquery
You can add it to your Django LOGGING settings:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'sqlhandler': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'sqlformatter'
}
},
'formatters': {
'sqlformatter': {
'()': 'ddquery.SqlFormatter',
'format': '%(levelname)s %(message)s',
},
},
'loggers': {
'django.db.backends': {
'handlers': ['sqlhandler'],
'level': 'DEBUG',
},
}
}
'formatters': {
'sqlformatter': {
'()': 'sqlformatter.SqlFormatter',
'format': '%(levelname)s %(message)s',
'reindent': False,
'highlight': False,
'keyword_case': 'lower'
},
},
python manage.py runserver
python manage.py shell
python manage.py migration