Registry / database / eventsourcing

eventsourcing

JSON →
library9.5.4pypypi✓ verified 85d 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.

pip install eventsourcing
INSTALL
IMPORT
SIG · EVENTSOURCING
E
eventsourcing
databasepythonv9.5.4
Install
1.7s avg
Import
77ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
from eventsourcing.domain import Aggregate
from eventsourcing.aggregate import Aggregate
Aggregate moved to eventsourcing.domain in v9.
Event
from eventsourcing.domain import Event
from eventsourcing.event import Event
Event classes are in eventsourcing.domain.
Application
from eventsourcing.application import Application
from eventsourcing.app import Application
Application has been in eventsourcing.application since early versions.
LogEvent
from eventsourcing.domain import LogEvent
from eventsourcing.events import LogEvent
LogEvent is part of the domain module.

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 issues
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.
fix
Change imports to from eventsourcing.domain import Aggregate, Event, etc.
affects: >=9.0.0
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.
fix
Decorate __init__ and other event-applying methods with @event('EventName').
affects: >=9.0.0
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.
fix
Use eventsourcing[postgres] or eventsourcing[sqlite] extras and configure via environment variables.
affects: >=9.5.0
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.
fix
Set os.environ['DB_URI'] = 'sqlite:///path/to/db' before instantiating app.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'eventsourcing.aggregate'
Aggregate class moved to eventsourcing.domain in v9.
fix
Use 'from eventsourcing.domain import Aggregate'.
TypeError: Can't instantiate abstract class Dog with abstract methods
Domain aggregate class missing @event decorator on __init__.
fix
Add '@event('Registered')' above __init__.
AttributeError: 'Dog' object has no attribute 'save'
Calling save on the aggregate instance directly instead of through application.
fix
Use 'self.save(dog)' inside the Application method, not dog.save()
Upgrade
Version history
9.5.4latest on PyPI · released Mar 27, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources
eventsourcing — pip install eventsourcing · libregistry