Data access layer for Spakky Framework (Repository implementations, ORM integration)
Project description
Spakky Data
Data access layer abstractions for Spakky Framework.
Installation
pip install spakky-data
Features
- Repository Pattern: Generic repository interfaces for aggregate persistence
- Transaction Management: Abstract transaction classes with autocommit support
- External Proxy: Proxy pattern for external service data access
Quick Start
Repository Pattern
Define repository interfaces for your domain aggregates:
from abc import abstractmethod
from uuid import UUID
from spakky.data.persistency.repository import IAsyncGenericRepository
from spakky.domain.models.aggregate_root import AbstractAggregateRoot
class User(AbstractAggregateRoot[UUID]):
name: str
email: str
class IUserRepository(IAsyncGenericRepository[User, UUID]):
@abstractmethod
async def find_by_email(self, email: str) -> User | None: ...
Transaction Management
Use abstract transactions for database operations:
from spakky.data.persistency.transaction import AbstractAsyncTransaction
class SQLAlchemyTransaction(AbstractAsyncTransaction):
def __init__(self, session_factory, autocommit: bool = True) -> None:
super().__init__(autocommit)
self.session_factory = session_factory
self.session = None
async def initialize(self) -> None:
self.session = self.session_factory()
async def dispose(self) -> None:
await self.session.close()
async def commit(self) -> None:
await self.session.commit()
async def rollback(self) -> None:
await self.session.rollback()
Usage with context manager:
async with transaction:
user = await repository.get(user_id)
user.name = "New Name"
await repository.save(user)
# Automatically commits on success, rollbacks on exception
External Proxy Pattern
Access external service data with proxy interfaces:
from spakky.data.external.proxy import ProxyModel, IAsyncGenericProxy
class ExternalUser(ProxyModel[int]):
name: str
email: str
class IExternalUserProxy(IAsyncGenericProxy[ExternalUser, int]):
pass
API Reference
Persistency
| Class | Description |
|---|---|
IGenericRepository |
Sync generic repository interface |
IAsyncGenericRepository |
Async generic repository interface |
AbstractTransaction |
Sync transaction with context manager |
AbstractAsyncTransaction |
Async transaction with context manager |
EntityNotFoundError |
Raised when entity not found |
External
| Class | Description |
|---|---|
ProxyModel |
Base class for external service data models |
IGenericProxy |
Sync proxy interface |
IAsyncGenericProxy |
Async proxy interface |
Errors
| Class | Description |
|---|---|
AbstractSpakkyPersistencyError |
Base error for persistency operations |
AbstractSpakkyExternalError |
Base error for external service operations |
Related Packages
| Package | Description |
|---|---|
spakky-domain |
DDD building blocks (Entity, AggregateRoot, ValueObject) |
spakky-event |
Event publisher/consumer interfaces |
License
MIT License
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 spakky_data-5.0.1.tar.gz.
File metadata
- Download URL: spakky_data-5.0.1.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1368b9eb6f2a8ff965e1401f862862aa54655c0cfea9ad8eae5057aff1966f6
|
|
| MD5 |
f13627b7630d5680d3ed1e440016d823
|
|
| BLAKE2b-256 |
f9083f77e6b08caa21aca44ead837a5e29efa564f17af86720b1d4cc3b7f5fe3
|
Provenance
The following attestation bundles were made for spakky_data-5.0.1.tar.gz:
Publisher:
release.yml on E5presso/spakky-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spakky_data-5.0.1.tar.gz -
Subject digest:
a1368b9eb6f2a8ff965e1401f862862aa54655c0cfea9ad8eae5057aff1966f6 - Sigstore transparency entry: 747186340
- Sigstore integration time:
-
Permalink:
E5presso/spakky-framework@8f29a1a51bb96bbc2d471d88362357d886e543ea -
Branch / Tag:
refs/heads/main - Owner: https://github.com/E5presso
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8f29a1a51bb96bbc2d471d88362357d886e543ea -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file spakky_data-5.0.1-py3-none-any.whl.
File metadata
- Download URL: spakky_data-5.0.1-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bb027aeef95fc634c9d8881b12816c6104bb13067427af38e059bcb9573e813
|
|
| MD5 |
269ed865f2988df9abb381a0c2262ea9
|
|
| BLAKE2b-256 |
c2a11ed76dbce1428454a6453f2da38669553ad4196f6ed34f6fe81677236987
|
Provenance
The following attestation bundles were made for spakky_data-5.0.1-py3-none-any.whl:
Publisher:
release.yml on E5presso/spakky-framework
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spakky_data-5.0.1-py3-none-any.whl -
Subject digest:
4bb027aeef95fc634c9d8881b12816c6104bb13067427af38e059bcb9573e813 - Sigstore transparency entry: 747186343
- Sigstore integration time:
-
Permalink:
E5presso/spakky-framework@8f29a1a51bb96bbc2d471d88362357d886e543ea -
Branch / Tag:
refs/heads/main - Owner: https://github.com/E5presso
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8f29a1a51bb96bbc2d471d88362357d886e543ea -
Trigger Event:
workflow_dispatch
-
Statement type: