Skip to main content

Postgres backend plugin for SimpleBroker

Project description

simplebroker-pg

Postgres backend plugin for SimpleBroker.

This package is intentionally separate from simplebroker itself. SimpleBroker remains SQLite-first. This package adds a Postgres backend through the public backend plugin hook.

Requirements

  • Python 3.10+
  • PostgreSQL
  • A dedicated schema for SimpleBroker tables

public is intentionally rejected.

Installation

# Fresh install through SimpleBroker's convenience extra
pipx install "simplebroker[pg]"

# Add to an existing pipx-installed simplebroker (recommended)
pipx inject simplebroker simplebroker-pg

# Or install through the convenience extra in a project
uv add "simplebroker[pg]"

# Or install the extension directly with uv
uv add simplebroker-pg

# Or install the extension directly with pip
pip install simplebroker-pg

simplebroker[pg] still installs this package as a separate distribution. Postgres support is not built into the default simplebroker install.

Python Usage

from simplebroker import Queue
from simplebroker_pg import PostgresRunner

runner = PostgresRunner(
    "postgresql://postgres@127.0.0.1:54329/simplebroker_test",
    schema="simplebroker_app",
)

queue = Queue("jobs", runner=runner, persistent=True)
queue.write("hello")
print(queue.read())

CLI Usage

Create .broker.toml in the project root:

version = 1
backend = "postgres"
target = "postgresql://postgres@127.0.0.1:54329/simplebroker_test"

[backend_options]
schema = "simplebroker_app"

Then use the normal CLI from any child directory with project scope enabled:

broker init
broker write jobs hello
broker read jobs

You can also run entirely from environment variables without a project config:

BROKER_BACKEND=postgres \
BROKER_BACKEND_TARGET='postgresql://postgres@127.0.0.1:54329/simplebroker_test' \
BROKER_BACKEND_SCHEMA='simplebroker_app' \
BROKER_BACKEND_PASSWORD='postgres' \
broker init

Notes:

  • In env-only backend configuration, BROKER_BACKEND_TARGET overrides the host/port/user/database parts.
  • BROKER_BACKEND_HOST, BROKER_BACKEND_PORT, BROKER_BACKEND_USER, BROKER_BACKEND_PASSWORD, and BROKER_BACKEND_DATABASE are only used when there is no target from project config or env.
  • When .broker.toml provides the target or schema, the project file wins. BROKER_BACKEND_PASSWORD can still be supplied from env and is never written to .broker.toml.
  • The Postgres database must already exist. broker init creates the managed schema/tables inside that database; it does not create the database itself.
  • Missing backend/plugin errors are distinct from target/auth errors. Invalid schema names, bad passwords, malformed targets, and missing databases are reported as validation or connection failures, not as "backend not available" errors.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simplebroker_pg-1.0.5.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

simplebroker_pg-1.0.5-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file simplebroker_pg-1.0.5.tar.gz.

File metadata

  • Download URL: simplebroker_pg-1.0.5.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for simplebroker_pg-1.0.5.tar.gz
Algorithm Hash digest
SHA256 3fa4ba0c5b095a40c31048255e3a0321fd1811978d1928797d873fe56823bd84
MD5 528d3630aa80c5801478b29969f2307b
BLAKE2b-256 0beb526044a885f0f3ea00fbc9026270a533c09dacff098ad43aaebe0f3fa2c2

See more details on using hashes here.

File details

Details for the file simplebroker_pg-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: simplebroker_pg-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for simplebroker_pg-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 fd0a6321aa892b3c7d821a5939e61ff009df32ef03b261f1d2035b8834bdf47e
MD5 74ce000f80179c72737f6add684938dd
BLAKE2b-256 d26d5409fc0b8a2b03b92061ad335986e7228a153fdbf68a88852d776343f0cc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page