pygeoapi is a Python server implementation of the OGC API suite of standards. The project emerged as part of the next generation OGC API efforts in 2018 and provides the capability for organizations to deploy a RESTful OGC API endpoint using OpenAPI, GeoJSON, and HTML. pygeoapi is open source and released under an MIT license.
I'm working on an OGC API EDR provider that is backed by a postgresql DB, which coincidentally is the same DB being used for exposing the same resource as an OGC API features collection.
Therefore I would like to reuse the same DB engine and table reflected models as the pygeoapi postgresql features provider. Unfortunately these are not currently exposed to code outside the postgresql feature provider.
This PR thus presents a light refactor of the pygeoapi.provider.postgresql.py module, with the intention of letting other providers make use of the engine and table caching facilities.
With this proposed implementation, the private method PostgreSQLProvider._get_engine_and_table_model() is replaced by two public functions:
get_engine()
get_table_model()
Both of these functions use the standard lib's functools.cache decorator, ensuring that they are cached.
Dependency policy (RFC2)
[x] I have ensured that this PR meets RFC2 requirements
[x] I'd like to contribute [feature X|bugfix Y|docs|something else] to pygeoapi. I confirm that my contributions to pygeoapi will be compatible with the pygeoapi license guidelines at the time of contribution
[x] I have already previously agreed to the pygeoapi Contributions and Licensing Guidelines
Overview
I'm working on an OGC API EDR provider that is backed by a postgresql DB, which coincidentally is the same DB being used for exposing the same resource as an OGC API features collection.
Therefore I would like to reuse the same DB engine and table reflected models as the pygeoapi postgresql features provider. Unfortunately these are not currently exposed to code outside the postgresql feature provider. This PR thus presents a light refactor of the
pygeoapi.provider.postgresql.py
module, with the intention of letting other providers make use of the engine and table caching facilities.With this proposed implementation, the private method
PostgreSQLProvider._get_engine_and_table_model()
is replaced by two public functions:get_engine()
get_table_model()
Both of these functions use the standard lib's functools.cache decorator, ensuring that they are cached.
Dependency policy (RFC2)
Updates to public demo
Contributions and licensing
(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)