Registry / database / eventsourcing

eventsourcing

JSON →
library9.5.4pypypi✓ verified 34d ago

A library for event sourcing in Python. It provides a framework for building applications using the event sourcing pattern, with support for aggregates, projections, and various persistence backends. Current version is 9.5.4, requiring Python >=3.10. Active development with regular releases.

databasedataworkflow
Install & Compatibility
Where this runs
tested against v9.5.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.080s · 19.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.074s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Aggregate moved to eventsourcing.domain in v9.

from eventsourcing.domain import Aggregate

Event classes are in eventsourcing.domain.

from eventsourcing.domain import Event

Application has been in eventsourcing.application since early versions.

from eventsourcing.application import Application

LogEvent is part of the domain module.

from eventsourcing.domain import LogEvent

Minimal example: define an aggregate with events, an application, and execute.

import os from eventsourcing.application import Application from eventsourcing.domain import Aggregate, event class Dog(Aggregate): @event('Registered') def __init__(self, name): self.name = name self.tricks = [] @event('TrickAdded') def add_trick(self, trick): self.tricks.append(trick) class DogSchool(Application): def register_dog(self, name): dog = Dog(name) self.save(dog) return dog.id def add_trick(self, dog_id, trick): dog = self.repository.get(dog_id) dog.add_trick(trick) self.save(dog) def get_dog(self, dog_id): return self.repository.get(dog_id) app = DogSchool() dog_id = app.register_dog('Fido') app.add_trick(dog_id, 'roll over') dog = app.get_dog(dog_id) print(f'{dog.name}: {dog.tricks}')
Debug
Known footguns
breakingIn v9, the domain model classes (Aggregate, Event, etc.) are no longer in the top-level package. They moved to eventsourcing.domain. Importing from old paths will raise ImportError.
breakingThe 'event' decorator for methods is now required to mark event constructor methods. In v8, event methods were inferred; in v9 they must be explicitly decorated.
deprecatedThe 'sqlalchemy' persistence module has been deprecated in favor of 'sqlalchemy' as an optional dependency via eventsourcing[postgres] or eventsourcing[sqlite]. Direct import from eventsourcing.persistence.sqlalchemy may be removed.
gotchaWhen using SQLite for persistence, the database file path must be set via environment variable DB_URI or passed to Application constructor. Not providing it will cause silent fallback to in-memory store which is not persisted.
Upgrade
Version history

Breaking-change detection hasn't run for this library yet.

Audit
Security & dependencies

CVE tracking and dependency tree are planned for a later release.

Agent activity
24 hits · last 30 days
bytedance
5
gptbot
4
ahrefsbot
3
claudebot
3
amazonbot
2
script
1
Resources