{ "info": { "author": "Fabio Pachelli Pacheco", "author_email": "nanook.labs@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Build Tools" ], "description": "# django-query-debugger\nPrints queries executed on you projects along with line traceback.\n\n## Table of Contents\n1. [Why Should I Use This?](#why-should-i-use-this?)\n2. [When Should I NOT Use This?](#when-should-i-not-use-this)\n3. [How To](#how-to)\n4. [Features](#features)\n5. [Usage](#usage)\n 1. [Singleton module](#singleton-module)\n 2. [On Django shell](#on-django-shell)\n 3. [Traceback feature](#traceback-feature)\n\n## Why Should I Use This?\n\nDjango ORM is great but ccan be a little obscure sometimes. Sometimes you want to know what queries your project is doing, some other times you see some weird looking querie running on your DB logs and have no ideia what triggered. This little lib helps with that.\n\n## When Should I NOT Use This?\n\nOn your production environment. This guy is working fine but you dont need to insert this lame-hacking-failure-point into you production code, do you?\n\n\n## How To\n\nJust import this file. See the [Usage](#usage) section for more information\n\n#### But remember:\n\nDo not use it on production. I love this little hack but IT'S NOT NEEDED FOR PRODUCTION\n\n\n## Features\n\n- Print out EVERY query you make using django ORM or django.db.connection directly\n- Print out EVERY query make by your, your framework or external libs\n- Print out ONLY query trigged by a specific file\n- Print usable strings for debug\n- Traceback query execution to related files\n\n# Usage:\n\n### Singleton module:\n- As Python's modules are singleton import this lib anywhere and it will affect the who project.\n\nFor example, when you hit a simple django view like this one:\n```python\n\"\"\"myproject/myapp/views.py\"\"\"\nfrom django.http import Http404\nfrom django.shortcuts import render\nfrom myapp.models import MyModel\nimport query_debugger\n\ndef detail(request, my_model_id):\n try:\n p = MyModel.objects.get(pk=my_model_id)\n except MyModel.DoesNotExist:\n raise Http404(\"MyModel does not exist\")\n return render(request, 'mymodel/detail.html', {'mymodel': p})\n```\n\nYour server output will look like this:\n```\n[12:03:23]myproject$ ./manage.py runserver\nPerforming system checks...\nSystem check identified no issues (0 silenced).\nMay 15, 2019 - 11:03:31\nDjango version 2.1, using settings 'myproject.settings'\nStarting development server at http://127.0.0.1:8000/\nQuit the server with CONTROL-C.\n[11:03:38] INFO \"GET /mymodel/1 HTTP/1.1\" 200 38346\n /Users/fabio/projects/myproject/myapp/views.py Line: 7\n SELECT \"myapp_mymodel\".\"id\", \"myapp_mymodel\".\"name\" FROM \"myapp_mymodel\" WHERE \"myapp_mymodel\".\"id\" = 1\n```\n\n### On Django shell\n```python\n>>> import query_debugger\n>>> from myapp.models import MyModel\n>>> MyModel.objects.count()\n/Users/fabio/envs/py36/lib/python3.6/site-packages/traitlets/config/application.py Line: 658\n /Users/fabio/envs/py36/lib/python3.6/site-packages/IPython/terminal/ipapp.py Line: 356\n /Users/fabio/envs/py36/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py Line: 489\n /Users/fabio/envs/py36/lib/python3.6/site-packages/IPython/core/interactiveshell.py Line: 3291\n Line: 1\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/db/models/query.py Line: 383\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/db/models/sql/query.py Line: 483\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/db/models/sql/compiler.py Line: 1061\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/db/backends/utils.py Line: 100\n SELECT COUNT(*) AS \"__count\" FROM \"myapp_mymodel\"\n3\n```\n\n### Traceback feature\n- The default behavior is to traceback only queries trigged by your code, ommiting queries trigged by the framework or libraries. However, if you want you can expand to any querie trigged anywhere like this:\n\n```python\n\"\"\"myproject/myapp/views.py\"\"\"\nimport query_debugger\nquery_debugger.everywhere()\n\n...\n```\n\nYour server output will look like this:\n```\n[12:03:23]myproject$ ./manage.py runserver\nPerforming system checks...\nSystem check identified no issues (0 silenced).\n/Users/fabio/envs/py36/lib/python3.6/site-packages/django/utils/autoreload.py Line: 225\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/core/management/commands/runserver.py Line: 120\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/core/management/base.py Line: 442\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/db/migrations/executor.py Line: 18\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/db/migrations/loader.py Line: 209\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/db/migrations/recorder.py Line: 62\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/db/models/query.py Line: 138\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/db/models/sql/compiler.py Line: 1061\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/db/backends/utils.py Line: 100\n SELECT \"django_migrations\".\"app\", \"django_migrations\".\"name\" FROM \"django_migrations\"\nMay 15, 2019 - 11:15:57\nDjango version 2.1, using settings 'thundera.settings'\nStarting development server at http://127.0.0.1:8000/\nQuit the server with CONTROL-C.\n[11:03:38] INFO \"GET /mymodel/1 HTTP/1.1\" 200 38346\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/contrib/auth/decorators.py Line: 20\n /Users/fabio/projects/myproject/myapp/views.py Line: 7\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/utils/functional.py Line: 347\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/contrib/auth/middleware.py Line: 12\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/contrib/auth/__init__.py Line: 189\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/contrib/auth/backends.py Line: 98\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/db/models/manager.py Line: 82\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/db/models/query.py Line: 54\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/db/models/sql/compiler.py Line: 1061\n /Users/fabio/envs/py36/lib/python3.6/site-packages/django/db/backends/utils.py Line: 100\n SELECT \"myapp_mymodel\".\"id\", \"myapp_mymodel\".\"name\" FROM \"myapp_mymodel\" WHERE \"myapp_mymodel\".\"id\" = 1\n```\n\nOr narrow down to the file where you imported the debugger:\n```python\n\"\"\"myproject/myapp/views.py\"\"\"\nimport query_debugger\nquery_debugger.here() # will only print queries trigged by myproject/myapp/views.py\n\n...\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/nano-labs/django-query-debugger/archive/0.0.2.zip", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/nano-labs/django-query-debugger", "keywords": "django query traceback print debug", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django-query-debugger", "package_url": "https://pypi.org/project/django-query-debugger/", "platform": "", "project_url": "https://pypi.org/project/django-query-debugger/", "project_urls": { "Download": "https://github.com/nano-labs/django-query-debugger/archive/0.0.2.zip", "Homepage": "https://github.com/nano-labs/django-query-debugger" }, "release_url": "https://pypi.org/project/django-query-debugger/0.0.2/", "requires_dist": null, "requires_python": "", "summary": "Prints queries executed on you projects along with line traceback.", "version": "0.0.2" }, "last_serial": 5272191, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "f31392bb11c12b9af5e2dbf9173e4386", "sha256": "a1ca8705cfde889876e100b3abb6ee862b7d9417e644e8d20456577b9773bdfb" }, "downloads": -1, "filename": "django_query_debugger-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f31392bb11c12b9af5e2dbf9173e4386", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4749, "upload_time": "2019-05-15T12:24:30", "url": "https://files.pythonhosted.org/packages/14/25/8a122b06a9ec6e64781ddca4d1cceabee4f7c21787e79b366d8d15dbc8fb/django_query_debugger-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0be027be6dc0aaa3fb1caeebba50762b", "sha256": "051b72658a88893bd3a21262d239da84536c4f506b0a44567b0ccee4924bb007" }, "downloads": -1, "filename": "django-query-debugger-0.0.2.tar.gz", "has_sig": false, "md5_digest": "0be027be6dc0aaa3fb1caeebba50762b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4981, "upload_time": "2019-05-15T12:24:33", "url": "https://files.pythonhosted.org/packages/32/aa/d2695ce4fe3c122aedc8ff94a0ce5449e2787289f91e7eb932f071a7653a/django-query-debugger-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f31392bb11c12b9af5e2dbf9173e4386", "sha256": "a1ca8705cfde889876e100b3abb6ee862b7d9417e644e8d20456577b9773bdfb" }, "downloads": -1, "filename": "django_query_debugger-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f31392bb11c12b9af5e2dbf9173e4386", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4749, "upload_time": "2019-05-15T12:24:30", "url": "https://files.pythonhosted.org/packages/14/25/8a122b06a9ec6e64781ddca4d1cceabee4f7c21787e79b366d8d15dbc8fb/django_query_debugger-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0be027be6dc0aaa3fb1caeebba50762b", "sha256": "051b72658a88893bd3a21262d239da84536c4f506b0a44567b0ccee4924bb007" }, "downloads": -1, "filename": "django-query-debugger-0.0.2.tar.gz", "has_sig": false, "md5_digest": "0be027be6dc0aaa3fb1caeebba50762b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4981, "upload_time": "2019-05-15T12:24:33", "url": "https://files.pythonhosted.org/packages/32/aa/d2695ce4fe3c122aedc8ff94a0ce5449e2787289f91e7eb932f071a7653a/django-query-debugger-0.0.2.tar.gz" } ] }