Installation¶
This guide covers how to install pgqrs for both Rust and Python projects.
Choose Your Backend¶
pgqrs supports both PostgreSQL and SQLite. Choose based on your needs:
| Backend | Best For | Prerequisites |
|---|---|---|
| PostgreSQL | Production, multi-worker | PostgreSQL 12+ server |
| SQLite | CLI tools, testing, embedded | None (embedded) |
See Backend Selection Guide for detailed comparison.
Library Installation¶
Using Cargo¶
Add pgqrs to your Cargo.toml:
[dependencies]
# PostgreSQL only (default)
pgqrs = "0.13.0"
# SQLite only
pgqrs = { version = "0.13.0", default-features = false, features = ["sqlite"] }
# Both backends
pgqrs = { version = "0.13.0", features = ["full"] }
# Required dependencies
tokio = { version = "0.13.0", features = ["full"] }
serde_json = "1"
pgqrs is async-first and works with Tokio.
Verify Installation¶
PostgreSQL Setup¶
Option 1: Docker (Recommended for Development)¶
# Start a PostgreSQL container
docker run --name pgqrs-postgres \
-e POSTGRES_PASSWORD=postgres \
-p 5432:5432 \
-d postgres:15
# Connection string
# postgresql://postgres:postgres@localhost:5432/postgres
Option 2: Local PostgreSQL¶
Install PostgreSQL using your system package manager:
Option 3: Cloud PostgreSQL¶
pgqrs works with any PostgreSQL-compatible database:
- AWS RDS - Get connection string from RDS console
- Google Cloud SQL - Get connection string from Cloud Console
- Azure Database for PostgreSQL - Get connection string from Azure portal
- Supabase - Get connection string from project settings
- Neon - Get connection string from dashboard
Installing the pgqrs Schema¶
Before using pgqrs, you need to install its schema in your database. You can do this via the CLI or programmatically.
use pgqrs::Config;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let dsn = "postgresql://localhost/mydb";
let store = pgqrs::connect(dsn).await?;
// Install schema
pgqrs::admin(&store).install().await?;
// Verify installation
pgqrs::admin(&store).verify().await?;
println!("Schema installed successfully!");
Ok(())
}
Custom Schema¶
By default, pgqrs creates tables in the public schema. To use a custom schema:
What's Next?¶
- Quickstart - Create your first queue and send messages
- Architecture - Understand how pgqrs works