This document describes an older version of Celery (2.5). For the latest stable version please go here.

Using SQLAlchemy

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:

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:

# sqlite (filename)
BROKER_URL = "sqla+sqlite:///celerydb.sqlite"

# mysql
BROKER_URL = "sqla+mysql://scott:tiger@localhost/foo"

# postgresql
BROKER_URL = "sqla+postgresql://scott:tiger@localhost/mydatabase"

# oracle
BROKER_URL = "sqla+oracle://scott:tiger@127.0.0.1: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 (celeryev, broadcast)
  • Events, including the Django Admin monitor.
  • Using more than a few workers (can lead to messages being executed multiple times).

Previous topic

Using Redis

Next topic

Using the Django Database

This Page