Skip to main content

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 server
  • create_database(name) - Create a new database
  • connect_database(name) - Connect to an existing database

Connection

Represents a connection to a specific database.

  • transact(events, constraints?) - Commit events atomically
  • latest_database() - Get the latest database state

DatabaseAtRevision

A point-in-time view of the database.

  • query_events(selector) - Query events matching a selector
  • view_state(name, version, params) - Get a state view

License

MIT OR Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

evidentsource_client-1.0.0rc1.tar.gz (34.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

evidentsource_client-1.0.0rc1-py3-none-any.whl (42.7 kB view details)

Uploaded Python 3

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

Hashes for evidentsource_client-1.0.0rc1.tar.gz
Algorithm Hash digest
SHA256 9a27fc18986e765a466420936cf1eed839e747b931d5e8278ff2c383d42f6e20
MD5 6f5f3fef6435586ae428df18115ce50e
BLAKE2b-256 518833a416cad97aea633b26ad74656e89c08a7f1c5327cc7d1f25e8cf4229b6

See more details on using hashes here.

File details

Details for the file evidentsource_client-1.0.0rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for evidentsource_client-1.0.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 73bcea0384b157e458815f81a16ac6f8ee679aaa53404b5871d5632d9998f93f
MD5 c23682e3db18dace3a32218346c586b8
BLAKE2b-256 4d5bf6777db7517ba54f8914121c0e5c32d9fff2006fe075b3599e85223a059a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page