Skip to content

Installation

This guide covers how to install pgqrs for both Rust and Python projects.

Prerequisites

  • PostgreSQL 12+ - pgqrs uses SKIP LOCKED and other features from PostgreSQL 12+
  • A PostgreSQL database you have access to (local, Docker, or cloud-hosted)

Library Installation

Using Cargo

Add pgqrs to your Cargo.toml:

[dependencies]
pgqrs = "0.4"
tokio = { version = "1", features = ["full"] }
serde_json = "1"

pgqrs is async-first and works with Tokio.

Verify Installation

use pgqrs::Config;

fn main() {
    let config = Config::from_dsn("postgresql://localhost/mydb");
    println!("pgqrs configured successfully!");
}

Using pip

pip install pgqrs
uv add pgqrs

Using Poetry

poetry add pgqrs

Verify Installation

import pgqrs
print("pgqrs installed successfully!")

PostgreSQL Setup

# 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:

brew install postgresql@15
brew services start postgresql@15
sudo apt-get update
sudo apt-get install postgresql-15
sudo systemctl start postgresql

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.

# Install the CLI
cargo install pgqrs

# Set your database connection
export PGQRS_DSN="postgresql://postgres:postgres@localhost:5432/postgres"

# Install the schema
pgqrs install

# Verify the installation
pgqrs verify
use pgqrs::{Admin, Config};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = Config::from_dsn("postgresql://localhost/mydb")?;
    let admin = Admin::new(&config).await?;

    // Install schema
    admin.install().await?;

    // Verify installation
    admin.verify().await?;

    println!("Schema installed successfully!");
    Ok(())
}
import pgqrs

# Connect to database
config = pgqrs.Config.from_dsn("postgresql://localhost/mydb")
admin = pgqrs.Admin(config)

# Install schema
admin.install()

# Verify installation
admin.verify()

print("Schema installed successfully!")

Custom Schema

By default, pgqrs creates tables in the public schema. To use a custom schema:

# Create the schema first (in psql)
# CREATE SCHEMA IF NOT EXISTS pgqrs;

# Install with custom schema
pgqrs --schema pgqrs install
let config = Config::from_dsn_with_schema(
    "postgresql://localhost/mydb",
    "pgqrs"
)?;
# Set schema during Admin initialization
admin = pgqrs.Admin(dsn, schema="pgqrs")

What's Next?