Create your connector¶
There are three ways you can specify the connection parameters:
Environment¶
You can use libpq environment variables (with PGPASSWORD
or pgpass
file):
$ export PGHOST=my.database.com # 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
procrastinate.AiopgConnector()
Data Source Name (DSN)¶
You can use aiopg dsn:
import procrastinate
procrastinate.AiopgConnector(dsn="postgres://user:password@host:port/dbname")
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).