$npx skillfedfor your agent

django-sql-utils

Improved API for aggregating using Subquery

With conditionsPyPI DatabaseReleased Sep 2023183.9K downloads / mopermissive licensePure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — django_sql_utils-0.7.0-py3-none-any.whl
v0.7.0 · released 2023-09-28 · Python >=3.8 · 2 runtime deps: django, sqlparse

Yes, if you are actively using Django and need to optimize aggregation queries. The package solves a real performance problem and has a clean API. However, verify compatibility with your Django version first—the package has been dormant since 2023-09-28 and may not work with very recent Django releases. No known security vulnerabilities.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Django and Python >= 3.8; the package is dormant and may not be compatible with very recent Django versions.
  • Low friction: pure Python wheel with only django and sqlparse as runtime dependencies.
  • Dormant since last commit on 2023-09-28; repository is not archived and has 143 stars, but no recent maintenance activity.

License · maintenance · safety

permissive license (permissive) — MIT license (permissive); you can use, modify, and distribute this package freely with minimal restrictions.

last release 2023-09-28 (1051 days) · last repo commit 2023-09-28 · 143 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 183,905 downloads/mo, #10,053 on PyPI

Verify before relying

pip install django-sql-utils

from django_sql_utils import SubqueryCount

Parent.objects.annotate(child_count=SubqueryCount('child'))
  • Compatibility with Django versions released after 2023-09-28 is unclear given the dormant maintenance status.
  • Whether sqlparse is used directly by the package or only as a transitive dependency of django.
  • The exact module path for importing SubqueryCount and other utilities from the package.
Same gist for agents: .md · .json

What it is and what it does

django-sql-utils wraps Django's queryset annotation API to generate more efficient SQL for common aggregation patterns. Instead of using Django's default JOIN-based aggregations, it provides subquery-based alternatives like SubqueryCount, SubqueryMin, SubqueryMax, SubquerySum, and SubqueryAvg that often perform better on large datasets. It also simplifies the syntax for annotating querysets with existence checks via a streamlined Exists API.

The package targets developers working with Django who need to optimize query performance or find Django's native aggregation syntax verbose. It depends on django and sqlparse as runtime dependencies and requires Python >= 3.8. The codebase has been dormant since 2023-09-28, so compatibility with the latest Django releases is not guaranteed without verification.

Use it for

  • Annotate a Parent queryset with a count of related Child objects using a subquery instead of a JOIN for better performance.
  • Add a boolean annotation to check whether a parent has any children, using a simpler API than Django's native Exists.
  • Use SubqueryAggregate with PostgreSQL aggregates to collect related field values without writing complex subquery syntax.
  • Replace verbose Django subquery and OuterRef patterns with cleaner, more maintainable annotation calls.
  • Optimize queries that would otherwise use GROUP BY and JOIN, which can be slower than subquery-based aggregation.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

With conditions

Yes, if you are actively using Django and need to optimize aggregation queries.

The package solves a real performance problem and has a clean API. However, verify compatibility with your Django version first—the package has been dormant since 2023-09-28 and may not work with very recent Django releases. No known security vulnerabilities.

Install

django-sql-utils on PyPI

Before you install

Low friction: pure Python wheel with only django and sqlparse as runtime dependencies. Dormant since last commit on 2023-09-28; repository is not archived and has 143 stars, but no recent maintenance activity.

Requires Django and Python >= 3.8; the package is dormant and may not be compatible with very recent Django versions.

License in practice

MIT license (permissive); you can use, modify, and distribute this package freely with minimal restrictions.

Quickstart

pip install django-sql-utils

from django_sql_utils import SubqueryCount

Parent.objects.annotate(child_count=SubqueryCount('child'))

Verify before relying

  • Compatibility with Django versions released after 2023-09-28 is unclear given the dormant maintenance status.
  • Whether sqlparse is used directly by the package or only as a transitive dependency of django.
  • The exact module path for importing SubqueryCount and other utilities from the package.

Package facts

Licensepermissive license permissive
Python supportSupports the current Python release >=3.8
Install frictionLow. Pure-Python wheel
Runtime dependencies
2 packages
djangosqlparse
MaintenanceDormant 1,051 days since the last release
Last repo commit
First released
Downloads183,905 / month, #10,053 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
License :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3

Evidence: django_sql_utils-0.7.0-py3-none-any.whl

Tags

Capabilities
django subquery aggregationdjango queryset optimizationdjango sql generationdjango count subquerydjango exists annotationdjango query performancedjango aggregate subquery
Topics
django-ormquery-optimizationsql-generation

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “django subquery aggregation”

  • django-sql-utilsProvides simplified APIs for Django querysets to generate optimized…
  • django-snowflakeProvides a Django database backend that connects Django ORM to…
  • python-logstashSends Python log records to Logstash over UDP or TCP, formatting them…

Give your agent the search over MCP, or paste the wish link into any chat.

More Database packages

psycopg2-binary Worth it
PyPI · Software Development · released Apr 2026

psycopg2-binary is a PostgreSQL database adapter for Python that implements the DB API 2.0 specification, enabling Python applications to connect to and query PostgreSQL databases with thread-safe concurrent operations.

copyleftcompiled wheel · 3.9+
271.6Mdownloads / mo
redis Worth it
PyPI · Database · released Jul 2026

Python client library for connecting to and executing commands against Redis key-value stores, supporting both synchronous and asynchronous operations.

Install it if your application needs to interact with Redis; the only prerequisite is a running Redis server instance.

MITpure Python · 3.10+
268.3Mdownloads / mo
ydb Worth it
PyPI · Database · released Jul 2026

YDB Python SDK is the official client library for connecting to and querying YDB databases from Python applications.

Install it if you need to connect Python applications to YDB databases.

permissive licensepure Python · 3.10+
210.0Mdownloads / mo
snowflake-connector-python Worth it
PyPI · Software Development · released Aug 2026

Connects Python applications to Snowflake data warehouses using the DB API 2.0 specification, enabling SQL queries, data transfers, and warehouse operations.

Apache-2.0compiled wheel · 3.10+
193.6Mdownloads / mo
sqlparse Worth it
PyPI · Software Development · released Aug 2026

sqlparse tokenizes SQL text into a tree of statements, clauses, and expressions, and provides functions to split scripts, format queries, and inspect parsed tokens without validating dialect or syntax.

Install it if you need to manipulate, format, or analyze SQL text programmatically.

BSD-3-Clausepure Python · 3.10+
148.9Mdownloads / mo
dbt-adapters With conditions
PyPI · Database · released Jul 2026

Provides base adapter protocols and shared functionality that database adapters use to integrate with dbt-core, handling connections, dialect translation, relation caching, and core interface management.

Apache-2.0pure Python · 3.10.0+
121.3Mdownloads / mo

See also django-tree-queries · django-cacheops · django-query-builder · django-mock-queries · django-chunkator · django-cte · django-pg-returning · gw-dsl-parser · django-pg-bulk-update · django-mysql