Create your connector

There are three ways you can specify the connection parameters:


You can use libpq environment variables (with PGPASSWORD or pgpass file):

$ export  # Either export the variables in your shell
$ PGPORT=5433 python -m myapp  # Or define the variables just for your process

and then define:

import procrastinate

Data Source Name (DSN)

You can use aiopg dsn:

import procrastinate

Connection arguments

You can use other aiopg connection arguments (which are the same as psycopg2 connection arguments):

import procrastinate
procrastinate.AiopgConnector(user="user", password="password", host="host")

Other arguments

Apart from connection parameters, the AiopgConnector receives all the parameters from the aiopg.create_pool().

What kind of Connector should I use?

Procrastinate currently provides 2 connectors:

  • AiopgConnector: Generic multipurpose connector. This should be the default.

  • Psycopg2Connector: This connector is specialized for synchronous calls only, and should only be used to configure your app for synchronous multi-threaded applications that need to defer tasks synchronously (see Synchronous deferring).