Skip to main content

actiongate-postgres

Shared PostgreSQL store adapter for ActionGate, BudgetGate, RuleGate, and AuditGate.

Uses psycopg (psycopg3) with connection pooling. One pool shared across all gate stores.

Install

pip install actiongate-postgres

# Install with specific gate support:
pip install actiongate-postgres[actiongate]
pip install actiongate-postgres[all]  # all four gates

Quickstart

import psycopg
from actiongate import Engine, Gate, Policy
from actiongate_postgres import ConnectionManager, ActionGatePostgresStore, create_tables

# Create shared pool
mgr = ConnectionManager("postgresql://localhost/mydb")

# Create tables (idempotent)
with mgr.pool.connection() as conn:
    create_tables(conn)

# Wire store to engine
store = ActionGatePostgresStore(mgr)
engine = Engine(store=store)

engine.register(Gate("api", "send_email", "user-42"), Policy(max_calls=5, window=60))
result = engine.check(Gate("api", "send_email", "user-42"))
print(result)  # Decision(status=ALLOW, ...)

mgr.close()

Async

from actiongate_postgres import AsyncConnectionManager, AsyncActionGatePostgresStore

async with AsyncConnectionManager("postgresql://localhost/mydb") as mgr:
    store = AsyncActionGatePostgresStore(mgr)
    # use with async engine...

Multiple Gates, One Pool

from actiongate_postgres import (
    ConnectionManager,
    ActionGatePostgresStore,
    BudgetGatePostgresStore,
    AuditGatePostgresStore,
    create_tables,
)

mgr = ConnectionManager("postgresql://localhost/mydb")

with mgr.pool.connection() as conn:
    create_tables(conn)

ag_store = ActionGatePostgresStore(mgr)
bg_store = BudgetGatePostgresStore(mgr)
audit_store = AuditGatePostgresStore(mgr)

Testing

# Start PostgreSQL
docker compose up -d

# Run tests
DATABASE_URL="postgresql://actiongate:actiongate@localhost/actiongate_test" pytest tests/ -v

License

Apache-2.0

Release files for actiongate-postgres 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for actiongate-postgres 0.1.0
File Size Uploaded
actiongate_postgres-0.1.0.tar.gz 15.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for actiongate-postgres 0.1.0
File Interpreter ABI Platform
actiongate_postgres-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 31.0 kB

Release files / actiongate_postgres-0.1.0.tar.gz

Download URL actiongate_postgres-0.1.0.tar.gz
Size 15.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6dddbbbc7d45a22a9b5202d510dda5b6a248d4668dc8cf0995e96af25c60e39c
BLAKE2b-256 checksum
How to use checksums
df6edfb72d0e887f275936c62108e266ac2523784992d39b1b904e9ea7dd3ae4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / actiongate_postgres-0.1.0-py3-none-any.whl

Download URL actiongate_postgres-0.1.0-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8b186ecfb5fdf9971bce238d888eb047e01aa1496085556c09f51b1f0f222071
BLAKE2b-256 checksum
How to use checksums
20bf9442922698464c8b838bff352da944f28d26927b4121a6318ae60dbe7b26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page