Skip to main content

A django middleware package to print out queries in the terminal

Project description

SQLInspector Middleware for Django

Version

Description

SQLInspector is a Django middleware that provides developers with insights into the SQL queries generated by Django's ORM. By integrating SQLInspector into your Django project, you can:

  • Monitor and capture all SQL queries in real-time.
  • Analyze the efficiency and performance of database operations.
  • Understand the underlying SQL interactions even when using Django's ORM for database operations.
  • Ensure that the application's database interactions are optimized for scalability and performance.

SQLInspector acts as a valuable tool for developers aiming to ensure the optimal performance of their Django applications, especially when dealing with complex database operations and multiple related models.

Features

  • Monitor and Log SQL Queries: Every SQL query made by your Django application is recorded.

  • Performance Optimization: Get insights into the most efficient ways of fetching data from your database and optimizing your queries accordingly.

  • Diagnostic Aid: Helps in diagnosing non-performant SQL queries and offers insights into potential optimizations.

  • Ease of Integration: Being a middleware, it seamlessly integrates into any Django project.

Installation

To install the SQLInspector middleware via pip, use:

pip install sql-inspector

How to Use

Integrating SQLInspector into your Django project is straightforward. Once you've installed the middleware, the next steps ensure its proper functioning:

Integration Steps:

  1. Add to MIDDLEWARE in settings.py:

    After you have installed the SQLInspector via pip, you need to add it to your Django application's MIDDLEWARE settings.

    Open your settings.py file and locate the MIDDLEWARE section. Add the following line:

    'sql-inspector.middleware.querychecker_middleware',
    

    Ensure you add it in the appropriate order. For instance, if you have other middleware that processes database queries, you might want to adjust the order to ensure SQLInspector captures the raw queries before any other processing takes place.

  2. Monitor Your Queries:

    With SQLInspector now integrated, you can monitor, analyze, and optimize your SQL queries in real-time as your application runs.

Remember, SQLInspector doesn't just capture the queries; it provides valuable insights into their performance and efficiency. By understanding the underlying SQL, you can make the necessary adjustments to your Django ORM operations, ensuring optimal database interactions.

Happy optimizing!

Contributor:

Aryaman Awasthi

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

sql-inspector-1.0.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

sql_inspector-1.0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file sql-inspector-1.0.1.tar.gz.

File metadata

  • Download URL: sql-inspector-1.0.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for sql-inspector-1.0.1.tar.gz
Algorithm Hash digest
SHA256 2366607b45bd1210cd8de197e0988d35a529f20a7219e7075e1a325494bae46e
MD5 7649a214456857095b6693337885b6f4
BLAKE2b-256 79181a7a6f8dbd227de27582aa99d0a50673a12b7c6749470e8ea7f8b59d4eda

See more details on using hashes here.

File details

Details for the file sql_inspector-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: sql_inspector-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for sql_inspector-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9e22abd06e7f4065a29f9dda0e7a399c1bbceff0f44ce1f953a4879b0e51f094
MD5 a9b97aad395ec9a02af4ff972e2da738
BLAKE2b-256 755a76f76a3874d705a60a851dd0889527bb5604d2f6c6e6e62d2da431109884

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