# 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:
```bash
pip install django-query-analyzer
```
2. Add "django_query_analyzer" to your `INSTALLED_APPS` setting in your Django project's `settings.py`:
```python
INSTALLED_APPS = [
...
'django_query_analyzer',
]
```
3. Add "django_query_analyzer.middleware.QueryAnalyzerMiddleware" to your project's `MIDDLEWARE` list in `settings.py`:
```python
MIDDLEWARE = [
...
"django_query_analyzer.middleware.QueryAnalyzerMiddleware",
]
```
4. Register the query analyzer URL patterns in your project's `urls.py`:
```python
from django.urls import path, include
urlpatterns = [
...
path("query-analyzer/", include("django_query_analyzer.urls")),
]
```
5. Run the following command to create the necessary database tables for the "django_query_analyzer" package:
```bash
python manage.py migrate
```
## Usage
1. Start your Django development server:
```bash
python manage.py runserver
```
2. Visit the query analyzer dashboard at [http://127.0.0.1:8000/query-analyzer/](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:
```python
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:
```python
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:
```python
PATHS_TO_EXCLUDE = ['/admin/','/swagger/']
```
Raw data
{
"_id": null,
"home_page": "",
"name": "django-query-analyzer",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "python,django,query,sql-query,query-analyzer,query-monitoring,query-analysis,django-query-analyzer,django-query-monitoring,django-query-analysis",
"author": "Muhammed Shaheen",
"author_email": "muhammedshaheen.tkb@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/0c/e3/086a71833a69eb671030936a5e983947fd799f8ad41b56ec279795437d70/django_query_analyzer-0.0.15.tar.gz",
"platform": null,
"description": "\n# Django Query Analyzer\n\nDjango Query Analyzer is a Django app that allows you to monitor and analyze the database queries executed by your Django application.\n\n## Installation\n\n1. Install the `django-query-analyzer` package using pip:\n\n ```bash\n pip install django-query-analyzer\n\n ```\n\n2. Add \"django_query_analyzer\" to your `INSTALLED_APPS` setting in your Django project's `settings.py`:\n\n ```python\n INSTALLED_APPS = [\n ...\n 'django_query_analyzer',\n ]\n ```\n\n3. Add \"django_query_analyzer.middleware.QueryAnalyzerMiddleware\" to your project's `MIDDLEWARE` list in `settings.py`:\n\n ```python\n MIDDLEWARE = [\n ...\n \"django_query_analyzer.middleware.QueryAnalyzerMiddleware\",\n ]\n ```\n\n4. Register the query analyzer URL patterns in your project's `urls.py`:\n\n ```python\n from django.urls import path, include\n\n urlpatterns = [\n ...\n path(\"query-analyzer/\", include(\"django_query_analyzer.urls\")),\n ]\n ```\n\n5. Run the following command to create the necessary database tables for the \"django_query_analyzer\" package:\n\n ```bash\n python manage.py migrate\n ```\n\n## Usage\n\n1. Start your Django development server:\n\n ```bash\n python manage.py runserver\n ```\n\n2. Visit the query analyzer dashboard at [http://127.0.0.1:8000/query-analyzer/](http://127.0.0.1:8000/query-analyzer/) in your web browser.\n\n## Configuration\n\nBy 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:\n\n```python\nMAX_QUERY_ANALYZER_RECORDS = 100\n```\n\n### Logging to Terminal\n\nYou 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.\n\nExample configuration in settings.py:\n\n```python\nENABLE_LOGGING_TO_TERMINAL = True\n```\n\n## Excluded Paths\n\nYou can configure excluded path by configuring the `PATHS_TO_EXCLUDE` on the `settings.py`.\nby 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.\n\nExample configuration in settings.py:\n\n```python\nPATHS_TO_EXCLUDE = ['/admin/','/swagger/']\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python package for query analysis and monitoring in Django",
"version": "0.0.15",
"project_urls": null,
"split_keywords": [
"python",
"django",
"query",
"sql-query",
"query-analyzer",
"query-monitoring",
"query-analysis",
"django-query-analyzer",
"django-query-monitoring",
"django-query-analysis"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4599e12ac51b208525f9d82656c3884639a6d9846774f51fe0ac129c071c3362",
"md5": "56ea9bdf7cfeca1917d6e6ed4899ae23",
"sha256": "98064ee0ae88cc61417251bef389723ed3cb09654c3b12f48b333411f9ecf193"
},
"downloads": -1,
"filename": "django_query_analyzer-0.0.15-py3-none-any.whl",
"has_sig": false,
"md5_digest": "56ea9bdf7cfeca1917d6e6ed4899ae23",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 8341,
"upload_time": "2023-11-21T04:05:05",
"upload_time_iso_8601": "2023-11-21T04:05:05.418625Z",
"url": "https://files.pythonhosted.org/packages/45/99/e12ac51b208525f9d82656c3884639a6d9846774f51fe0ac129c071c3362/django_query_analyzer-0.0.15-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0ce3086a71833a69eb671030936a5e983947fd799f8ad41b56ec279795437d70",
"md5": "e493686c6e69267d06979d09a8bbeebb",
"sha256": "1904f17fd759bceccf2b0e47b3491ef6daf9de7af2fc1c6e671a739baee347b2"
},
"downloads": -1,
"filename": "django_query_analyzer-0.0.15.tar.gz",
"has_sig": false,
"md5_digest": "e493686c6e69267d06979d09a8bbeebb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6885,
"upload_time": "2023-11-21T04:05:09",
"upload_time_iso_8601": "2023-11-21T04:05:09.771463Z",
"url": "https://files.pythonhosted.org/packages/0c/e3/086a71833a69eb671030936a5e983947fd799f8ad41b56ec279795437d70/django_query_analyzer-0.0.15.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-21 04:05:09",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "django-query-analyzer"
}