Installation¶
Install the Package¶
PgQueuer supports two PostgreSQL drivers. Choose the one that fits your stack:
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 |
opentelemetry |
OpenTelemetry 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, failed) |
fn_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