Menu

pledge: a fast double-entry ledger inside PostgreSQL, ready for Django
📰

pledge: a fast double-entry ledger inside PostgreSQL, ready for Django

DEV Community: postgres·3 days ago
#QZM74Vtm
#devtopostgresql#devto#dev#pledge#transfer
Reading 0:00
15s threshold

...

Posted on Nov 12

Edited on Nov 12

AI-assisted

pledge is a double-entry ledger that runs inside PostgreSQL, with a Django package on top. If your app moves money, credits or points, it keeps the books for you:

Balanced by design. Every transfer writes two entries that sum to zero.

History built in. Each entry stores the running balance, so you can ask for any past balance.

Safe retries. Send your own transfer id; the same transfer twice is booked once.

Tamper-resistant. Ledger rows can't be deleted or edited; accounts are closed, never removed.

Fast. Written in Rust, one SQL statement per transfer or batch.

Django first

With django-pledge the ledger looks like ordinary Django models:

pip install django-pledge

Enter fullscreen mode

Exit fullscreen mode

INSTALLED_APPS = [ . . . , "django_pledge" ]

Enter fullscreen mode

Exit fullscreen mode

from decimal import Decimal from django_pledge . models import Account , Transfer

cash = Account . objects .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.