<commit_before># Django simple SQL log

Goal: provide a middleware that inserts start/stop annotations that would
land on the SQL logs.

The middlewares available have been tested only with Postgresql databases, but
it should work with other SQL-based RDBMs.

## Usage

Add this package to your requirements, and install it the usual way. You don't
have to add the application to the ``INSTALLED_APPS``, there's no model to sync.

Add the middlewares like this:

```python
MIDDLEWARE_CLASSES = (
    'django_sql_log.middleware.RequestLoggingMiddleware',
    # ...
    'django_sql_log.middleware.ResponseLoggingMiddleware',
)
```

Although the order of the middlewares is not crucial, it is better to make sure
that the RequestLoggingMiddleware is near the first place in the list, and the<commit_msg>log example on the readme<commit_after># Django simple SQL log

Goal: provide a middleware that inserts start/stop annotations that would
land on the SQL logs.

Like this:

    2014-12-08 09:33:58 CET LOG:  duration: 0.174 ms  statement: BEGIN
    2014-12-08 09:33:58 CET LOG:  duration: 0.502 ms  statement: SET TIME ZONE 'UTC'
    2014-12-08 09:33:58 CET LOG:  duration: 0.053 ms  statement: COMMIT
    2014-12-08 09:33:58 CET LOG:  duration: 0.228 ms  statement: SHOW default_transaction_isolation
    2014-12-08 09:33:58 CET LOG:  duration: 0.043 ms  statement: BEGIN
    2014-12-08 09:33:58 CET LOG:  duration: 0.354 ms  statement: SELECT 'django_sql_log_demo.views.Index_START'
    2014-12-08 09:33:58 CET LOG:  duration: 1.221 ms  statement: SELECT "dummy_article"."id", "dummy_article"."title", "dummy_article"."body" FROM "dummy_article"
    2014-12-08 09:33:58 CET LOG:  duration: 0.118 ms  statement: SELECT 'django_sql_log_demo.views.Index_STOP'
    2014-12-08 09:33:58 CET LOG:  duration: 0.067 ms  statement: ROLLBACK
    2014-12-08 09:33:59 CET LOG:  duration: 0.179 ms  statement: BEGIN
    2014-12-08 09:33:59 CET LOG:  duration: 0.513 ms  statement: SET TIME ZONE 'UTC'
    2014-12-08 09:33:59 CET LOG:  duration: 0.054 ms  statement: COMMIT
    2014-12-08 09:33:59 CET LOG:  duration: 0.231 ms  statement: SHOW default_transaction_isolation
    2014-12-08 09:34:00 CET LOG:  duration: 117.999 ms  statement: DROP DATABASE "test_hello_world"


The middlewares available have been tested only with Postgresql databases, but
it should work with other SQL-based RDBMs.

## Usage

Add this package to your requirements, and install it the usual way. You don't
have to add the application to the ``INSTALLED_APPS``, there's no model to sync.

Add the middlewares like this:

```python
MIDDLEWARE_CLASSES = (
    'django_sql_log.middleware.RequestLoggingMiddleware',
    # ...
    'django_sql_log.middleware.ResponseLoggingMiddleware',
)
```

Although the order of the middlewares is not crucial, it is better to make sure
that the RequestLoggingMiddleware is near the first place in the list, and the
{'fraction_non_alphanumeric': 0.08307586680398214, 'fraction_numerical': 0.0871953312736011, 'mean_word_length': 4.130281690140845, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '36739', 'n_tokens_mistral': 1134, 'n_tokens_neox': 933, 'n_words': 354}