Skip to main content

Simple SQL Middleware for Django

Project description

Django SQL Middleware

A simple middleware aimed to capture all queries in a request and provide basic SQL profiling such as execution time, execution plan, and query traceback.

This package is only intended to run in development mode for non-sqlite database.

Currently, this package only tested in projects that uses psycopg2 (postgres) as default database engine.

How To Install

  1. Get the package from pypi: pip install django-sql-middleware

  2. In settings.py add:

    INSTALLED_APPS = [
        # your other apps
        "sqlmiddleware"
    ]
    
    MIDDLEWARE = [
        # your other middlewares
    ]
    
    if DEBUG:
        MIDDLEWARE.append("sqlmiddleware.middlewares.LogSQLMiddleware")
    
  3. Register urls in your_project/urls.py:

    from django.urls import include, path
    
    urlpatterns = [
        # other urls,
        path("__sql/", include("sqlmiddleware.urls")),
    ]
    
  4. Run collectstatic to serve included css and js assets: ./manage.py collectstatic

  5. Start the development server: ./manage.py runserver

  6. you should be able to access localhost:8000/__sql in your browser.

Project details


Download files

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

Files for django-sql-middleware, version 0.0.7
Filename, size File type Python version Upload date Hashes
Filename, size django_sql_middleware-0.0.7-py3-none-any.whl (111.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-sql-middleware-0.0.7.tar.gz (106.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page