skillfed

django-mysql

Django-MySQL extends Django's built-in MySQL and MariaDB support their specific features not available on other databases.

django-mysql v4.19.0 742.8K downloads/30d#5,179 on PyPI589
Permissive license MIT Active released

What it is and what it does

Django-MySQL is a bridge library that unlocks MySQL and MariaDB capabilities within Django's ORM that would otherwise be unavailable. It provides QuerySet extensions for efficient pagination and approximate counting, specialized model fields like MariaDB Dynamic Columns and comma-separated fields, direct access to over 20 MySQL-specific SQL functions, and utilities for database-level operations like named locks and table management.

The package is designed for Django projects that have committed to MySQL or MariaDB and want to leverage database-specific optimizations and features. It integrates directly into Django's model and queryset layers, so usage typically involves importing custom field classes or manager methods rather than learning a separate API. The library maintains compatibility with current Django versions (4.2 through 6.0) and modern Python (3.9+), with no external compiled dependencies beyond what Django itself requires.

Use it for:

  • Optimize pagination on large querysets using chunked iteration instead of loading all results into memory.
  • Get quick row count estimates using approx_count instead of expensive COUNT(*) queries on massive tables.
  • Store semi-structured data like configuration dictionaries using MariaDB Dynamic Columns without a separate JSON column.
  • Implement application-level locking on shared resources using MySQL named locks without external lock services.
  • Leverage MySQL-specific functions like JSON operations or string functions directly in ORM expressions.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Django-MySQL extends Django's ORM with MySQL and MariaDB-specific features including QuerySet optimizations, specialized model fields, MySQL functions, and database utilities not available in Django's generic database layer.

Yes, if your Django project uses MySQL or MariaDB and you need database-specific optimizations or features. The package is actively maintained, has no known vulnerabilities, carries a permissive MIT license, and integrates cleanly with current Django versions. Install friction is minimal. If you use PostgreSQL or SQLite, this package provides no value.

Install

django-mysql on PyPI

pip

pip install django-mysql

uv

uv add django-mysql

poetry

poetry add django-mysql

Installing django-mysql

Before you install

Low install friction with a single pure-Python wheel dependency on django. Actively maintained with recent commits and a stable production release status across Django 4.2 through 6.0 and Python 3.9 through 3.14.

License in practice

MIT license permits free use, modification, and distribution with minimal restrictions, making it suitable for both open-source and commercial projects.

Quickstart

pip install django-mysql

from django_mysql.models import QuerySet
from django.db import models

class MyModel(models.Model):
    objects = QuerySet.as_manager()
    class Meta:
        db_table = 'my_table'

Requires Django and MySQL/MariaDB as the project database; features are only available when using MySQL or MariaDB, not other database backends.

Verify before relying

  • Whether approx_count performance gains are significant for typical table sizes in production environments.
  • Compatibility guarantees with MySQL versions beyond those explicitly tested in CI.
  • Performance characteristics of the MySQL upsert-based cache backend compared to standard Django cache backends.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 1 — django
Maintenance actively maintained — 330 days since the last release
Last repo commit
First released
Downloads 742,761/month — #5,179 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: django_mysql-4.19.0-py3-none-any.whl

Keywords: Django, MariaDB, MySQL

Development Status :: 5 - Production/StableFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.0Framework :: Django :: 5.1Framework :: Django :: 5.2Framework :: Django :: 6.0Intended Audience :: DevelopersNatural Language :: EnglishOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: DatabaseTyping :: Typed

Tags

django mysql mariadb extensionsdjango orm mysql specific featuresmysql queryset optimizationdjango mysql cache backendmariadb dynamic columns django
django-extensionmysql-mariadborm-optimization

More Database packages