Python package for query analysis and monitoring in Django
Project description
Django Query Analyzer
Django Query Analyzer is a Django app that allows you to monitor and analyze the database queries executed by your Django application.
Installation
-
Install the
django-query-analyzer
package using pip:pip install django-query-analyzer
-
Add "django_query_analyzer" to your
INSTALLED_APPS
setting in your Django project'ssettings.py
:INSTALLED_APPS = [ ... 'django_query_analyzer', ]
-
Add "django_query_analyzer.middleware.QueryAnalyzerMiddleware" to your project's
MIDDLEWARE
list insettings.py
:MIDDLEWARE = [ ... "django_query_analyzer.middleware.QueryAnalyzerMiddleware", ]
-
Register the query analyzer URL patterns in your project's
urls.py
:from django.urls import path, include urlpatterns = [ ... path("query-analyzer/", include("django_query_analyzer.urls")), ]
-
Run the following command to create the necessary database tables for the "django_query_analyzer" package:
python manage.py migrate
Usage
-
Start your Django development server:
python manage.py runserver
-
Visit the query analyzer dashboard at http://127.0.0.1:8000/query-analyzer/ in your web browser.
Configuration
By default, the query analyzer stores the last 50 executed queries. If you want to control this number, you can add the MAX_QUERY_ANALYZER_RECORDS
setting to your project's settings.py
. For example, to store the last 100 queries, add the following line to your settings.py:
MAX_QUERY_ANALYZER_RECORDS = 100
Logging to Terminal
You can control logging to the terminal by adding the ENABLE_LOGGING_TO_TERMINAL
setting to your project's settings.py
. If set to True
, query analysis details will be printed to the terminal. To disable terminal logging, set it to `False.
Example configuration in settings.py:
ENABLE_LOGGING_TO_TERMINAL = True
Excluded Paths
You can configure excluded path by configuring the PATHS_TO_EXCLUDE
on the settings.py
.
by adding the list of path prefixes, you can ignore the execution of query analyzer on the paths. By default query analyzer execute on every paths.
Example configuration in settings.py:
PATHS_TO_EXCLUDE = ['/admin/','/swagger/']
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_query_analyzer-0.0.15.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1904f17fd759bceccf2b0e47b3491ef6daf9de7af2fc1c6e671a739baee347b2 |
|
MD5 | e493686c6e69267d06979d09a8bbeebb |
|
BLAKE2b-256 | 0ce3086a71833a69eb671030936a5e983947fd799f8ad41b56ec279795437d70 |
Hashes for django_query_analyzer-0.0.15-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98064ee0ae88cc61417251bef389723ed3cb09654c3b12f48b333411f9ecf193 |
|
MD5 | 56ea9bdf7cfeca1917d6e6ed4899ae23 |
|
BLAKE2b-256 | 4599e12ac51b208525f9d82656c3884639a6d9846774f51fe0ac129c071c3362 |