{"id":29216781,"url":"https://github.com/nano-labs/django-query-debugger","last_synced_at":"2026-04-22T23:33:37.714Z","repository":{"id":57421464,"uuid":"186806578","full_name":"nano-labs/django-query-debugger","owner":"nano-labs","description":"Prints queries executed on you projects along with line traceback.","archived":false,"fork":false,"pushed_at":"2019-11-11T17:47:16.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-29T02:38:34.061Z","etag":null,"topics":["debugger","django","query-debugger","sql"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nano-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-15T10:45:38.000Z","updated_at":"2020-11-05T20:50:46.000Z","dependencies_parsed_at":"2022-09-10T13:21:04.838Z","dependency_job_id":null,"html_url":"https://github.com/nano-labs/django-query-debugger","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/nano-labs/django-query-debugger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nano-labs%2Fdjango-query-debugger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nano-labs%2Fdjango-query-debugger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nano-labs%2Fdjango-query-debugger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nano-labs%2Fdjango-query-debugger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nano-labs","download_url":"https://codeload.github.com/nano-labs/django-query-debugger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nano-labs%2Fdjango-query-debugger/sbom","scorecard":{"id":673985,"data":{"date":"2025-08-11","repo":{"name":"github.com/nano-labs/django-query-debugger","commit":"6f343c31c52eaf6e367ea6b70482f00eb59621ca"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/11 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}}]},"last_synced_at":"2025-08-21T20:59:25.075Z","repository_id":57421464,"created_at":"2025-08-21T20:59:25.075Z","updated_at":"2025-08-21T20:59:25.075Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32159957,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T17:06:48.269Z","status":"ssl_error","status_checked_at":"2026-04-22T17:06:19.037Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debugger","django","query-debugger","sql"],"created_at":"2025-07-03T01:04:34.386Z","updated_at":"2026-04-22T23:33:37.690Z","avatar_url":"https://github.com/nano-labs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 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- Install with\n```\npip install django-query-debugger\n```\n\n-Then just import this lib with\n\n```python\nimport query_debugger\n```\nSee 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\u003e\u003e\u003e import query_debugger\n\u003e\u003e\u003e from myapp.models import MyModel\n\u003e\u003e\u003e MyModel.objects.count()\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#### Max Depth\n\nA max_depth argument may be added to query_debugger.everywhere(max_depth=10) or query_debugger.here(max_depth=10) to change how deep the traceback will go.\n\nEx: max_depth=50\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/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/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\nEx: max_depth=0\n```\n[12:03:23]myproject$ ./manage.py runserver\nPerforming system checks...\nSystem check identified no issues (0 silenced).\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  SELECT \"myapp_mymodel\".\"id\", \"myapp_mymodel\".\"name\" FROM \"myapp_mymodel\" WHERE \"myapp_mymodel\".\"id\" = 1\n```\n\n#### everywhere()\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/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/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\n#### here()\n\nNarrow 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```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnano-labs%2Fdjango-query-debugger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnano-labs%2Fdjango-query-debugger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnano-labs%2Fdjango-query-debugger/lists"}