csrd-repository
Base repository and database adapter abstractions for FastAPI microservices.
Package: csrd.repository · Import: from csrd.repository import BaseRepository, SQLiteAdapter
What's included
BaseRepository— abstract repository with model parsing (requires an adapter)ABCDatabaseAdapter/DBProtocol— async database adapter abstraction with lifecycle and explicit transactionsSQLiteAdapter— async SQLite implementation via aiosqlite (persistent connection, atomic upsert)ExecuteResult— immutable snapshot of query metadata (replaces raw cursor return)- Optional
sqlalchemyintegration for query building (pip install csrd-repository[sql])
Installation
uv pip install "csrd-repository @ git+ssh://git@github.com/csrd-api/fastapi-common.git#subdirectory=packages/repository"
Dependencies
csrd-models(Tier 2)
Transactions
All adapters expose an explicit unit-of-work context:
async with adapter.transaction() as tx:
users = user_repository.with_adapter(tx)
credentials = credential_repository.with_adapter(tx)
user = await users.insert("users", user_values)
await credentials.insert("credentials", {"user_id": user["id"], **credential_values})
The yielded adapter uses one physical connection. Normal exit commits;
exceptions and cancellation roll back. Nested transaction() calls are
rejected with RuntimeError, and a transaction-bound adapter raises
RuntimeError if reused after context exit.
Locking remains database-specific: PostgreSQL and MariaDB support their native
row-lock syntax (for example SELECT ... FOR UPDATE); SQLite serializes
operations on its single connection and does not support FOR UPDATE.
Metadata
Release files for csrd-repository 0.6.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 | |
|---|---|---|---|
| csrd_repository-0.6.0.tar.gz | 15.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| csrd_repository-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.2 kB
Release files / csrd_repository-0.6.0.tar.gz
| Download URL | csrd_repository-0.6.0.tar.gz |
|---|---|
| Size | 15.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
601d7b2290b6f017697db6e274f6ada6eeefb080342fa9177ebe5e53ba9384a5
|
|
BLAKE2b-256 checksum How to use checksums |
13bf6bf074814c9fc54abd471b10e6c9a56bfb93edc9a29d2ab7d07110523b9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.
Transparency logRelease files / csrd_repository-0.6.0-py3-none-any.whl
| Download URL | csrd_repository-0.6.0-py3-none-any.whl |
|---|---|
| Size | 16.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c231e687f40912f4f24a98f8a849a313d82dbaf0cd60c453c80749b7abe13aa4
|
|
BLAKE2b-256 checksum How to use checksums |
7bb29e27d2f24b8011c58e85473e0b77acd066231025465a1fe0376455ce4a32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.
Transparency log