Installation¶
Install the Package¶
PgQueuer supports two PostgreSQL drivers. Choose the one that fits your stack:
asyncpg is a high-performance async driver written in Cython. It provides the best throughput for PgQueuer workloads.
psycopg supports both async and synchronous connections. Use this if you need to enqueue jobs from sync code (e.g. Flask, Django) or already use psycopg elsewhere in your application.
Optional extras
You can install additional integrations alongside your driver:
| Extra | Purpose |
|---|---|
asyncpg |
asyncpg async driver |
psycopg |
psycopg async + sync driver |
logfire |
Logfire distributed tracing |
sentry |
Sentry distributed tracing |
mcp |
MCP server for AI agent access |
fastapi |
FastAPI Prometheus metrics router |
Install multiple extras at once:
Set Up the Database Schema¶
PgQueuer stores jobs, schedules, and logs in PostgreSQL tables. Create them with the CLI:
This creates the following objects in your database:
| Object | Type | Purpose |
|---|---|---|
pgqueuer |
Table | Active job queue |
pgqueuer_log |
Table | Completed job audit trail |
pgqueuer_statistics |
Table | Job processing statistics |
pgqueuer_schedules |
Table | Cron schedule definitions |
pgqueuer_status |
Enum | Job status values (queued, picked, successful, exception, canceled, deleted) |
pgqueuer_changed |
Function | PL/pgSQL function that sends pg_notify() on queue changes |
tg_pgqueuer_changed |
Trigger | Fires the notify function on INSERT/UPDATE/DELETE/TRUNCATE |
Verify the Installation¶
Confirm all PgQueuer objects are present:
This exits with code 0 if the schema is correctly installed, or code 1 if anything is missing.
Connection Configuration¶
PgQueuer reads standard PostgreSQL environment variables:
| Variable | Purpose | Default |
|---|---|---|
PGHOST |
Database host | localhost |
PGPORT |
Database port | 5432 |
PGUSER |
Database user | current OS user |
PGPASSWORD |
Database password | — |
PGDATABASE |
Database name | same as user |
You can also pass a connection string directly when constructing drivers in code.
Table Prefix¶
To run multiple isolated PgQueuer instances in the same database, set a custom prefix:
This prefixes all table names, the enum type, the trigger, and the NOTIFY channel.
Next Steps¶
- Quick Start -- build your first consumer and producer
- Core Concepts -- understand the mental model behind PgQueuer