Python client for EvidentSource event sourcing database
Project description
EvidentSource Client for Python
Python client for the EvidentSource event sourcing database.
Installation
pip install evidentsource-client
Usage
import asyncio
from evidentsource_client import EvidentSource
from evidentsource_core import DatabaseName, Selector, ProspectiveEvent, StringEventData
async def main():
# Connect to the server
async with await EvidentSource.connect("localhost:50051") as es:
# Create a database
db_name = DatabaseName("my-app")
await es.create_database(db_name)
# Connect to the database
conn = await es.connect_database(db_name)
# Transact events
events = [
ProspectiveEvent(
id="evt-1",
stream="orders",
event_type="OrderCreated",
data=StringEventData('{"orderId": "123"}'),
)
]
db = await conn.transact(events)
print(f"Committed at revision: {db.revision}")
# Query events
db = await conn.latest_database()
async for event in db.query_events(Selector.stream("orders")):
print(f"Event: {event.id} - {event.event_type}")
asyncio.run(main())
API
EvidentSource
The main entry point for connecting to an EvidentSource server.
EvidentSource.connect(address)- Connect to a servercreate_database(name)- Create a new databaseconnect_database(name)- Connect to an existing database
Connection
Represents a connection to a specific database.
transact(events, constraints?)- Commit events atomicallylatest_database()- Get the latest database state
DatabaseAtRevision
A point-in-time view of the database.
query_events(selector)- Query events matching a selectorview_state(name, version, params)- Get a state view
License
MIT OR Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file evidentsource_client-1.0.0rc1.tar.gz.
File metadata
- Download URL: evidentsource_client-1.0.0rc1.tar.gz
- Upload date:
- Size: 34.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a27fc18986e765a466420936cf1eed839e747b931d5e8278ff2c383d42f6e20
|
|
| MD5 |
6f5f3fef6435586ae428df18115ce50e
|
|
| BLAKE2b-256 |
518833a416cad97aea633b26ad74656e89c08a7f1c5327cc7d1f25e8cf4229b6
|
File details
Details for the file evidentsource_client-1.0.0rc1-py3-none-any.whl.
File metadata
- Download URL: evidentsource_client-1.0.0rc1-py3-none-any.whl
- Upload date:
- Size: 42.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73bcea0384b157e458815f81a16ac6f8ee679aaa53404b5871d5632d9998f93f
|
|
| MD5 |
c23682e3db18dace3a32218346c586b8
|
|
| BLAKE2b-256 |
4d5bf6777db7517ba54f8914121c0e5c32d9fff2006fe075b3599e85223a059a
|