[](https://travis-ci.org/patrickporto/kant)
[](https://codecov.io/github/patrickporto/kant?branch=master)
[](https://pypi.python.org/pypi/kant)
[](https://pypi.python.org/pypi/kant)
[](https://pypi.python.org/pypi/kant)
A CQRS and Event Sourcing framework, safe for humans.
## Feature Support
* Event Store
* Optimistic concurrency control
* JSON serialization
* SQLAlchemy Projections
* Snapshots **[IN PROGRESS]**
Kant officially supports Python 3.5-3.6.
## Getting started
Create declarative events
```python
from kant import events
class BankAccountCreated(events.Event):
id = events.CUIDField(primary_key=True)
owner = events.CharField()
class DepositPerformed(events.Event):
amount = events.DecimalField()
```
Create aggregate to apply events
```python
from kant import aggregates
class BankAccount(aggregates.Aggregate):
id = aggregates.CUIDField()
owner = aggregates.CharField()
balance = aggregates.DecimalField()
def apply_bank_account_created(self, event):
self.id = event.id
self.owner = event.owner
self.balance = 0
def apply_deposit_performed(self, event):
self.balance += event.amount
```
Now, save the events
```python
from kant.eventstore import connect
await connect(user='user', password='user', database='database')
# create event store for bank_account
conn.create_keyspace('bank_account')
# create events
bank_account_created = BankAccountCreated(
id=123,
owner='John Doe',
)
deposit_performed = DepositPerformed(
amount=20,
)
bank_account = BankAccount()
bank_account.dispatch([bank_account_created, deposit_performed])
bank_account.save()
stored_bank_account = BankAccount.objects.get(123)
```
## Installing
To install Kant, simply use [pipenv](pipenv.org) (or pip)
```bash
$ pipenv install kant
```
## Contributing
Please, read the contribute guide [CONTRIBUTING](CONTRIBUTING.md).
Metadata
Release files for kant 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kant-2.1.0.tar.gz | 9.0 kB | Without provenance | Details for kant-2.1.0.tar.gz |
Release files / kant-2.1.0.tar.gz
| Download URL | kant-2.1.0.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ceac36edfeddb8ab55fefc0d8853dcf03d0c89bb594c2d069cd556e5c5d3075
|
|
BLAKE2b-256 checksum How to use checksums |
b608c104b9c0170b676b24c21100695271fff7853c56bb18ea3792b88f373cf9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for kant 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.