PR Title Check / check-title (pull_request) Successful in 7s
Code Quality Pipeline / code-quality (pull_request) Failing after 19s
Test Python Package / unit-tests (pull_request) Successful in 47s
Test Python Package / integration-tests (pull_request) Successful in 44s
Test Python Package / coverage-report (pull_request) Successful in 11s
Introduce PostgresAdapter for dict-based row CRUD via psycopg3, including config, lazy exports, unit/integration tests with testcontainers, and an example UserTableRepository. Co-authored-by: Cursor <cursoragent@cursor.com>
20 lines
604 B
Python
20 lines
604 B
Python
"""Example domain repository backed by Postgres tables."""
|
|
|
|
from typing import Any
|
|
|
|
from python_repositories.adapters.postgres_adapter import PostgresAdapter
|
|
|
|
|
|
class UserTableRepository(PostgresAdapter):
|
|
"""Example: domain repository backed by a Postgres table."""
|
|
|
|
def get_user(self, user_id: str) -> dict[str, Any] | None:
|
|
return self.fetch_one(user_id)
|
|
|
|
def save_user(self, user_id: str, user: dict[str, Any]) -> None:
|
|
row = {self._config.primary_key: user_id, **user}
|
|
self.upsert(row)
|
|
|
|
def delete_user(self, user_id: str) -> None:
|
|
self.delete(user_id)
|