Add Postgres table adapter with TableRepositoryInterface.
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
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 <[email protected]>
This commit is contained in:
co-authored by
Cursor
parent
f28d3c4844
commit
dc6f8a3e89
@@ -0,0 +1,19 @@
|
||||
"""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)
|
||||
Reference in New Issue
Block a user