skip to navigation
skip to content

django-mysqlpool 0.1-4

Django database backend for MySQL that provides pooling ala SQLAlchemy.

Latest Version: 0.1-9

A SmartFile Open Source project. Read more about how SmartFile uses and contributes to Open Source software.


This is a simple Django database backend that pools MySQL connections. This backend is based on a blog post by Ed Menendez.

The main differences being:

  1. The work is done for you.
  2. Instead of cloning the Django mysql backend, we import it.

The actual pooling is done using SQLAlchemy. While imperfect (this backend is per-process only) it has usefulness. The main problem it solves for us is that it restricts a process to a certain number of total connections.


Configure this backend instead of the default Django mysql backend.

    'default': {
        'ENGINE': 'django_mysqlpool.backends.mysqlpool',
        'NAME': 'db_name',
        'USER': 'username',
        'PASSWORD': 'password',
        'HOST': '',
        'PORT': '',


You can define the pool implementation and the specific arguments passed to it. The available implementations (backends) and their arguments are defined within the SQLAlchemy documentation.

  • MYSQLPOOL_BACKEND - The pool implementation name (‘QueuePool’ by default).
  • MYSQLPOOL_ARGUMENTS - The kwargs passed to the pool.

For example, to use a QueuePool without threadlocal, you could use the following configuration:

    'use_threadlocal': False,