Bases: Base
Abstract implementation of SQLAlchemy Base
Must be kept in line with
https://github.com/geopython/pygeoapi/blob/master/tests/data/postgres_manager_full_structure.backup.sql
Source code in docs/rs-dpr-service/rs_dpr_service/jobs_table.py
| class JobsTable(Base): # pylint: disable=too-few-public-methods
"""
Abstract implementation of SQLAlchemy Base
Must be kept in line with
https://github.com/geopython/pygeoapi/blob/master/tests/data/postgres_manager_full_structure.backup.sql
"""
__tablename__ = "jobs"
type = Column(Enum(JobType), nullable=False, server_default=JobType.process.value)
identifier = Column(String, primary_key=True, unique=True, index=True)
processID = Column(String, nullable=False)
status = Column(Enum(JobStatus), nullable=False)
progress = Column(Integer, server_default="0", nullable=False)
# Pylint issue with func.now, check this: https://github.com/sqlalchemy/sqlalchemy/issues/9189
created = Column(DateTime, server_default=func.now()) # pylint: disable=not-callable
started = Column(DateTime, server_default=func.now()) # pylint: disable=not-callable
finished = Column(DateTime) # pylint: disable=not-callable
# onupdate=func.now(), server_onupdate=func.now() is not working, did not figure why
# instead, force the PostgreSQLManager from pygeoapi to update the updated column specifically with
# update_job function (check processors.py log_job_execution function)
updated = Column(
DateTime,
server_default=func.now(), # pylint: disable=not-callable
onupdate=func.now(), # pylint: disable=not-callable
server_onupdate=func.now(), # pylint: disable=not-callable
)
location = Column(String)
mimetype = Column(String)
message = Column(String)
def __init__(self, *args, **kwargs):
"""Invoked when creating a new record in the database table."""
super().__init__(*args, **kwargs)
self.lock = Lock()
@orm.reconstructor
def init_on_load(self):
"""Invoked when retrieving an existing record from the database table."""
self.lock = Lock()
|
__init__(*args, **kwargs)
Invoked when creating a new record in the database table.
Source code in docs/rs-dpr-service/rs_dpr_service/jobs_table.py
| def __init__(self, *args, **kwargs):
"""Invoked when creating a new record in the database table."""
super().__init__(*args, **kwargs)
self.lock = Lock()
|
init_on_load()
Invoked when retrieving an existing record from the database table.
Source code in docs/rs-dpr-service/rs_dpr_service/jobs_table.py
| @orm.reconstructor
def init_on_load(self):
"""Invoked when retrieving an existing record from the database table."""
self.lock = Lock()
|