Skip to main content

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

  1. Install the django-query-analyzer package using pip:

    pip install django-query-analyzer
    
  2. Add "django_query_analyzer" to your INSTALLED_APPS setting in your Django project's settings.py:

    INSTALLED_APPS = [
        ...
        'django_query_analyzer',
    ]
    
  3. Add "django_query_analyzer.middleware.QueryAnalyzerMiddleware" to your project's MIDDLEWARE list in settings.py:

    MIDDLEWARE = [
        ...
        "django_query_analyzer.middleware.QueryAnalyzerMiddleware",
    ]
    
  4. 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")),
    ]
    

Usage

  1. Start your Django development server:

    python manage.py runserver
    
  2. 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

You can control the SQL query to logging the terminal by adding ENABLE_QUERY_LOGGING_ON_CONSOLE to the settings

ENABLE_QUERY_LOGGING_ON_CONSOLE = 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_query_analyzer-0.0.17.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_query_analyzer-0.0.17-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file django_query_analyzer-0.0.17.tar.gz.

File metadata

  • Download URL: django_query_analyzer-0.0.17.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for django_query_analyzer-0.0.17.tar.gz
Algorithm Hash digest
SHA256 d80945414620821f3862b475dc0f2a163ca3f2cf7e09682c771654d71b91c6be
MD5 ca2e62a2ef85cecfbb7c4b293ecd6324
BLAKE2b-256 5bcc80dbdb8bb69cbdc2d4b59b74c124f9aab12f463189638adf51827a9ea673

See more details on using hashes here.

File details

Details for the file django_query_analyzer-0.0.17-py3-none-any.whl.

File metadata

File hashes

Hashes for django_query_analyzer-0.0.17-py3-none-any.whl
Algorithm Hash digest
SHA256 49b2b72aeadb9afec457a91f7fc249399dfabab0405a71b6ba4c2117a27bd619
MD5 189e9dc8947d773225c9ca49ffcd15b6
BLAKE2b-256 9e1043f86f2219eb3bf829922dc0253d622bc1897d8a436695c8508736ab1acf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page