Registry / database / csrd-repository

csrd-repository

JSON →
library0.5.28pypypiunverified

Base repository and database adapter abstractions for CSRD API projects. Current version 0.5.28, rapid development with frequent releases.

pip install csrd-repository
INSTALL
IMPORT
SIG · CSRD-REPOSITORY
C
csrd-repository
databasepythonv0.5.28
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BaseRepository
✓ from csrd import BaseRepository
✗ from csrd.repository import BaseRepository

Minimal implementation of a repository adapter

from csrd.repository import BaseRepository, RepositoryAdapter from typing import Any, Dict, List, Optional class MyRepository(RepositoryAdapter): async def get(self, id: str) -> Optional[Dict[str, Any]]: return {"id": id, "name": "example"} async def list(self, filters: Optional[Dict[str, Any]] = None) -> List[Dict[str, Any]]: return [{"id": "1", "name": "example"}] async def create(self, data: Dict[str, Any]) -> Dict[str, Any]: return data async def update(self, id: str, data: Dict[str, Any]) -> Optional[Dict[str, Any]]: return {"id": id, **data} async def delete(self, id: str) -> bool: return True repo = MyRepository() print(repo.get("test"))
Debug
Known issues
breakingIn v0.5.0 the adapter base class was renamed from `BaseAdapter` to `RepositoryAdapter`. Code using `BaseAdapter` will break.
fix
Replace `from csrd.repository import BaseAdapter` with `from csrd.repository import RepositoryAdapter` and update class definitions.
affects: >=0.5.0
deprecatedThe `csrd.repository.adapters.SQLAlchemyRepository` now requires an async engine; synchronous usage is deprecated and will be removed in v0.6.0.
fix
Use `from sqlalchemy.ext.asyncio import create_async_engine` and pass `engine` to the repository.
affects: 0.5.x
gotchaWhen using the built-in `SQLAlchemyRepository`, you must call `await repository.init()` before any CRUD operations. Skipping this will raise `RuntimeError: Repository not initialized`.
fix
Add `await repository.init()` after instantiation, typically inside an async lifespan or on startup event.
affects: >=0.4.0
gotchaThe `BaseRepository` no longer provides a default `session` context manager. Code relying on `self.session` as a property will fail.
fix
Override `get_session` method or use `RepositoryAdapter` directly for custom implementations.
affects: >=0.5.20
Upgrade
Version history
0.5.28latest on PyPI · released May 18, 2026
Audit
Dependencies
sqlalchemyoptionalRequired for SQL database adapter implementations
pydanticoptionalUsed for data validation and settings management
Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
1
Resources
csrd-repository — pip install csrd-repository · libregistry