Contents
pg_accumulator — Python Demo
A simple web application demonstrating the core capabilities of the pg_accumulator extension.
What It Demonstrates
- Register creation —
register_create()(runs automatically on startup) - Posting movements —
register_post()via a web form - Canceling documents —
register_unpost() - Current balances — reading from
balance_cache(O(1)) - Balance queries —
inventory_balance()with filters and historical dates - Movement history — browsing recent operations
Getting Started
cd demo/python
docker compose up --build
Open in browser: http://localhost:3301
Project Structure
demo/python/
app.py — Flask backend
templates/index.html — Web interface
init.sql — Register creation + seed data
docker-compose.yml — PostgreSQL with pg_accumulator + Flask app
Dockerfile — Flask container
Demo Walkthrough
- Open http://localhost:3301
- See initial balances (6 movements are pre-loaded)
- Post a new receipt:
receipt:5, warehouse 1, product 1, quantity 50, amount 25000 - Observe that the balance updates instantly
- Cancel document
receipt:5— the balance reverts to its previous state - Query balance at date
2026-04-05— see the warehouse state at that historical point
Shutdown
docker compose down -v