PostgresRepository module (ska_db_oda.persistence.infrastructure.postgres.repository)
This module contains implementations of the AbstractRepository class, using Postgres as the data store.
- class ska_db_oda.persistence.infrastructure.postgres.repository.PostgresBridge(postgres_mapping: PostgresMapping, connection: psycopg.Connection)[source]
Implementation of the Repository bridge which persists entities in a PostgreSQL instance.
- create(entity: T, user: str | None = None) T[source]
Implementation of the RepositoryBridge method.
See
create()docstring for details
- query(qry_params: QueryParams) List[T][source]
Queries the latest version of the entity based on QueryParams class from the ODA and returns the corresponding entity ID
Returns an empty list if no entities in the repository match the parameters.
- Raises:
QueryParameterError – if the qry_params are not supported
ODAError – if an error occurs while querying the entity
- read(entity_id: U, version: U | None = None) T[source]
Implementation of the RepositoryBridge method.
See
read()docstring for details :param entity_id: provided entity_id for filter records :result: result based on mapped entity
- read_relationship(entity_id: U, parent_entity: U, associated_entity: U) T[source]
Implementation of the RepositoryBridge method. Generate query based on parent_entity, associated_entity and execute the query to get the result. See
read()docstring for details :param entity_id: provided entity_id for filter records :param parent_entity: relational primary entity table name :param associated_entity: relational secondary entity table name :result: Result based on parent and associated entity relationship on given entity id