Using SQLAlchemy

Experimental Status

The SQLAlchemy transport is unstable in many areas and there are several issues open. Sadly we don’t have the resources or funds required to improve the situation, so we’re looking for contributors and partners willing to help.

Installation

Configuration

Celery needs to know the location of your database, which should be the usual SQLAlchemy connection string, but with ‘sqla+’ prepended to it:

  1. BROKER_URL = 'sqla+sqlite:///celerydb.sqlite'

This transport uses only the BROKER_URL setting, which have to be an SQLAlchemy database URI.

Please see SQLAlchemy: Supported Databases for a table of supported databases.

Here’s a list of examples using a selection of other SQLAlchemy Connection String‘s:

  1. # sqlite (filename)
  2. BROKER_URL = 'sqla+sqlite:///celerydb.sqlite'
  3. # mysql
  4. BROKER_URL = 'sqla+mysql://scott:[email protected]/foo'
  5. # postgresql
  6. BROKER_URL = 'sqla+postgresql://scott:[email protected]/mydatabase'
  7. # oracle
  8. BROKER_URL = 'sqla+oracle://scott:[email protected]:1521/sidname'

Results

To store results in the database as well, you should configure the result backend. See Database backend settings.

Limitations

The SQLAlchemy database transport does not currently support:

  • Remote control commands (celery events command, broadcast)
  • Events, including the Django Admin monitor.
  • Using more than a few workers (can lead to messages being executed multiple times).