Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gabrielhora/django_sqlformatter

Format and syntax highlight SQL queries in Django log
https://github.com/gabrielhora/django_sqlformatter

django logging sql

Last synced: about 1 month ago
JSON representation

Format and syntax highlight SQL queries in Django log

Awesome Lists containing this project

README

        

# Django SQL Formatter

Format (sqlparse) and syntax highlight (pygments) SQL queries in Django.

#### Install

pip install django-sqlformatter

#### Configure

```python
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'sql': {
'()': 'django_sqlformatter.SqlFormatter',
},
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'sql',
},
},
'loggers': {
'django.db.backends': {
'handlers': ['console'],
'level': 'DEBUG',
}
}
}
```

---

#### Before

![before](before.png)

#### After

![after](after.png)