$npx skillfedfor your agent

django-query-builder

Build complex nested queries

With conditionsPyPI DatabaseReleased Jul 2026231.0K downloads / moMITPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — django_query_builder-4.0.0-py2.py3-none-any.whl
v4.0.0 · released 2026-07-07 · Python >=3.10 · 1 runtime deps: Django

Yes, if you work with Django and Postgres and regularly hit the limits of Django's ORM for complex or dynamic queries. The low install friction, active maintenance, permissive license, and zero known vulnerabilities make it a safe choice. Not necessary if your queries fit comfortably within Django querysets or if you're not using Postgres.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Postgres 14+; Django 5.2–6.0; Python 3.10–3.14.
  • Not compatible with other database backends.
  • Low friction install with a single Django dependency.

License · maintenance · safety

MIT (permissive) — MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.

last release 2026-07-07 (38 days) · last repo commit 2026-07-07 · 178 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 231,008 downloads/mo, #9,100 on PyPI

Verify before relying

pip install django-query-builder

from django_query_builder import QueryBuilder

qb = QueryBuilder().select('*').from_('users').where('age > 21')
results = qb.execute()
  • Scope of SQL operations supported beyond upsert (e.g., window functions, CTEs, complex joins)
  • Performance characteristics on large result sets or deeply nested queries
  • Postgres-only limitation: whether other databases are supported despite the requirement listing
  • Specific example usage patterns and API surface for dynamic query construction
Same gist for agents: .md · .json

What it is and what it does

django-query-builder is a Django library that lets you construct and execute SQL queries programmatically, filling gaps where Django's ORM and .raw() fall short. It's designed for developers who need to build queries dynamically—where the structure itself changes based on runtime conditions—rather than writing static raw SQL strings. The library mirrors SQL syntax closely in its API, so function calls map directly to SQL keywords, making the query construction process more transparent than Django querysets but requiring more SQL familiarity than the ORM.

The package sits between Django's high-level querysets (simple, safe, but limited) and raw SQL strings (flexible but not dynamic). It requires Django 5.2–6.0, Python 3.10–3.14, and Postgres 14+, and depends only on Django itself. It's actively maintained, has no known security vulnerabilities, and carries a permissive MIT license.

Use it for

  • Build upsert (insert-or-update) operations that Django's ORM doesn't natively support
  • Construct WHERE clauses, JOINs, or GROUP BY logic dynamically based on user input or application state
  • Execute complex nested queries or subqueries that would be awkward to express in Django querysets
  • Perform batch database operations with custom logic
  • Generate reports or analytics queries with conditional aggregations

Worth the install?

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

With conditions

Yes, if you work with Django and Postgres and regularly hit the limits of Django's ORM for complex or dynamic queries.

The low install friction, active maintenance, permissive license, and zero known vulnerabilities make it a safe choice. Not necessary if your queries fit comfortably within Django querysets or if you're not using Postgres.

Install

django-query-builder on PyPI

Before you install

Low friction install with a single Django dependency. Active maintenance as of 2026-07-07, last commit recent. Supports modern Python versions (3.10–3.14) and current Django releases (5.2–6.0).

Requires Postgres 14+; Django 5.2–6.0; Python 3.10–3.14. Not compatible with other database backends.

License in practice

MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.

Quickstart

pip install django-query-builder

from django_query_builder import QueryBuilder

qb = QueryBuilder().select('*').from_('users').where('age > 21')
results = qb.execute()

Verify before relying

  • Scope of SQL operations supported beyond upsert (e.g., window functions, CTEs, complex joins)
  • Performance characteristics on large result sets or deeply nested queries
  • Postgres-only limitation: whether other databases are supported despite the requirement listing
  • Specific example usage patterns and API surface for dynamic query construction

Package facts

LicenseMIT permissive
Python supportSupports the current Python release >=3.10
Install frictionLow. Pure-Python wheel
Runtime dependencies
1 package
Django
MaintenanceActively maintained 38 days since the last release
Last repo commit
First released
Downloads231,008 / month, #9,100 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Framework :: DjangoFramework :: Django :: 5.2Framework :: Django :: 6.0Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Evidence: django_query_builder-4.0.0-py2.py3-none-any.whl

Tags

Capabilities
django dynamic sql query buildercomplex nested sql queries djangoraw sql query constructionpostgres upsert djangoadvanced database operations djangosql query generation librarydjango custom sql builder
Topics
django-orm-alternativepostgres-nativedynamic-queries
PyPI keywords
djangodatabasequerysqlpostgresupsert

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 dynamic sql query builder”

  • django-query-builderBuilds and executes complex SQL queries dynamically in Django…
  • PyPikaPyPika is a Python API for building SQL queries programmatically…
  • django-sql-explorerA Django-based SQL query editor and business intelligence tool that…

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-mock-queries · PyPika · SQLAlchemy · django-cte · pypika-tortoise · django-sql-utils · django-zen-queries · django-sql-explorer · django-pgactivity · buildpg