All Projects → bradmontgomery → Django Querycount

bradmontgomery / Django Querycount

Licence: mit
Middleware that Prints the number of DB queries to the runserver console.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Django Querycount

Django Databrowse
Databrowse is a Django application that lets you browse your data.
Stars: ✭ 41 (-85.36%)
Mutual labels:  database, django
Django Balancer
A set of tools for using Django's multi-db feature.
Stars: ✭ 111 (-60.36%)
Mutual labels:  database, django
Android Debug Database
A library for debugging android databases and shared preferences - Make Debugging Great Again
Stars: ✭ 7,946 (+2737.86%)
Mutual labels:  database, debugging
Django Smuggler
Django Smuggler is a pluggable application for Django Web Framework that helps you to import/export fixtures via the automatically-generated administration interface.
Stars: ✭ 350 (+25%)
Mutual labels:  database, django
Django Sharding
A sharding library for Django
Stars: ✭ 184 (-34.29%)
Mutual labels:  database, django
Django Watchman
django-watchman exposes a status endpoint for your backing services like databases, caches, etc.
Stars: ✭ 357 (+27.5%)
Mutual labels:  database, django
Django Auth0 Vue
A Django REST Framework + Vue.js CRUD Demo Secured Using Auth0
Stars: ✭ 99 (-64.64%)
Mutual labels:  database, django
Tutorialdb
A search 🔎 engine for programming/dev tutorials, See it in action 👉
Stars: ✭ 93 (-66.79%)
Mutual labels:  django, developer-tools
Usaspending Api
Server application to serve U.S. federal spending data via a RESTful API
Stars: ✭ 166 (-40.71%)
Mutual labels:  database, django
Android Remote Debugger
A library for remote logging, database debugging, shared preferences and network requests
Stars: ✭ 132 (-52.86%)
Mutual labels:  database, debugging
Awesome Cheatsheets
👩‍💻👨‍💻 Awesome cheatsheets for popular programming languages, frameworks and development tools. They include everything you should know in one single file.
Stars: ✭ 26,007 (+9188.21%)
Mutual labels:  database, django
Django Migration Linter
🚀 Detect backward incompatible migrations for your django project
Stars: ✭ 231 (-17.5%)
Mutual labels:  database, django
Architect
A set of tools which enhances ORMs written in Python with more features
Stars: ✭ 320 (+14.29%)
Mutual labels:  database, django
Faker
Faker is a pure Elixir library for generating fake data.
Stars: ✭ 673 (+140.36%)
Mutual labels:  database, developer-tools
Django Redis Metrics
Metrics for django apps backed by Redis.
Stars: ✭ 93 (-66.79%)
Mutual labels:  django, developer-tools
Prequel
Prequel for Laravel. Clear and concise database management.
Stars: ✭ 1,141 (+307.5%)
Mutual labels:  database, developer-tools
Best Of Python Dev
🏆 A ranked list of awesome python developer tools and libraries. Updated weekly.
Stars: ✭ 243 (-13.21%)
Mutual labels:  developer-tools, debugging
Httpie
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie
Stars: ✭ 53,052 (+18847.14%)
Mutual labels:  developer-tools, debugging
Dksnap
Docker Snapshots for Development and Test Data
Stars: ✭ 122 (-56.43%)
Mutual labels:  database, developer-tools
Django Markupfield
📑 a MarkupField for Django
Stars: ✭ 184 (-34.29%)
Mutual labels:  database, django

Django Querycount

|version| |license|

Inspired by this post by David Szotten <http://goo.gl/UUKN0r>_, this project gives you a middleware that prints DB query counts in Django's runserver console output.

|screenshot|

Installation

pip install django-querycount

Just add querycount.middleware.QueryCountMiddleware to your MIDDLEWARE.

Notice that django-querycount is hard coded to work only in DEBUG mode set to true

Settings

There are two possible settings for this app: The first defines threshold values used to color output, while the second allows you customize requests that will be ignored by the middleware. The default settings are::

QUERYCOUNT = {
    'THRESHOLDS': {
        'MEDIUM': 50,
        'HIGH': 200,
        'MIN_TIME_TO_LOG':0,
        'MIN_QUERY_COUNT_TO_LOG':0
    },
    'IGNORE_REQUEST_PATTERNS': [],
    'IGNORE_SQL_PATTERNS': [],
    'DISPLAY_DUPLICATES': None,
    'RESPONSE_HEADER': 'X-DjangoQueryCount-Count'
}

The QUERYCOUNT['THRESHOLDS'] settings will determine how many queries are interpreted as high or medium (and the color-coded output). In previous versions of this app, this settings was called QUERYCOUNT_THRESHOLDS and that setting is still supported.

The QUERYCOUNT['IGNORE_REQUEST_PATTERNS'] setting allows you to define a list of regexp patterns that get applied to each request's path. If there is a match, the middleware will not be applied to that request. For example, the following setting would bypass the querycount middleware for all requests to the admin::

QUERYCOUNT = {
    'IGNORE_REQUEST_PATTERNS': [r'^/admin/']
}

The QUERYCOUNT['IGNORE_SQL_PATTERNS'] setting allows you to define a list of regexp patterns that ignored to statistic sql query count. For example, the following setting would bypass the querycount middleware for django-silk sql query::

QUERYCOUNT = {
    'IGNORE_SQL_PATTERNS': [r'silk_']
}

The QUERYCOUNT['RESPONSE_HEADER'] setting allows you to define a custom response header that contains the total number of queries executed. To disable this header, the supply None as the value::

QUERYCOUNT = {
    'RESPONSE_HEADER': None
}

New in 0.4.0. The QUERYCOUNT['DISPLAY_DUPLICATES'] setting allows you to control how the most common duplicate queries are displayed. If the setting is None (the default), duplicate queries are not displayed. Otherwise, this should be an integer. For example, the following setting would always print the 5 most duplicated queries::

QUERYCOUNT = {
    'DISPLAY_DUPLICATES': 5,
}

License

This code is distributed under the terms of the MIT license.

Testing

Run python manage.py test querycount to run the tests. Note that this will modify your settings so that your project is in DEBUG mode for the duration of the querycount tests.

(side-note: this project needs better tests; for the moment, there are only smoke tests that set up the middleware and call two simple test views).

Contributing

Bug fixes and new features are welcome! Fork this project and send a Pull Request to have your work included. Be sure to add yourself to AUTHORS.rst.

.. |version| image:: http://img.shields.io/pypi/v/django-querycount.svg?style=flat-square :alt: Current Release :target: https://pypi.python.org/pypi/django-querycount/

.. |license| image:: http://img.shields.io/pypi/l/django-querycount.svg?style=flat-square :alt: License :target: https://pypi.python.org/pypi/django-querycount/

.. |screenshot| image:: screenshot.png :alt: django-querycount in action

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].