Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ jobs:
with:
postgresql password: ${{ secrets.DatabasePassword || 'postgres' }}
postgresql db: 'test'

- name: "Install and run MySQL 📦"
uses: mirromutth/mysql-action@v1.1
with:
host port: 3306
mysql version: '8.0'
mysql database: test_geo_app
mysql root password: mysql # This is a dummy password here; not actually used in prod
mysql user: pygeoapi
mysql password: mysql

- name: Install and run Elasticsearch 📦
uses: getong/elasticsearch-action@v1.2
with:
Expand Down Expand Up @@ -111,6 +122,7 @@ jobs:
psql postgresql://postgres:${{ secrets.DatabasePassword || 'postgres' }}@localhost:5432/test -f tests/data/dummy_data.sql
psql postgresql://postgres:${{ secrets.DatabasePassword || 'postgres' }}@localhost:5432/test -f tests/data/dummy_types_data.sql
psql postgresql://postgres:${{ secrets.DatabasePassword || 'postgres' }}@localhost:5432/test -f tests/data/postgres_manager_full_structure.backup.sql
mysql -h 127.0.0.1 -P 3306 -u root -p'mysql' test_geo_app < tests/data/mysql_data.sql
docker ps
python3 tests/load_oracle_data.py
- name: run unit tests ⚙️
Expand Down Expand Up @@ -142,6 +154,7 @@ jobs:
pytest tests/test_oracle_provider.py
pytest tests/test_parquet_provider.py
pytest tests/test_postgresql_provider.py
pytest tests/test_mysql_provider.py
pytest tests/test_rasterio_provider.py
pytest tests/test_sensorthings_edr_provider.py
pytest tests/test_sensorthings_provider.py
Expand Down
71 changes: 71 additions & 0 deletions docs/source/data-publishing/ogcapi-features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ parameters.
`ESRI Feature Service`_,✅/✅,results/hits,✅,✅,✅,✅,❌,❌,❌,✅
`GeoJSON`_,✅/✅,results/hits,❌,❌,❌,✅,❌,❌,❌,✅
`MongoDB`_,✅/❌,results,✅,✅,✅,✅,❌,❌,❌,✅
`MySQL`_,✅/✅,results/hits,✅,✅,✅,✅,❌,✅,✅,✅
`OGR`_,✅/❌,results/hits,✅,❌,❌,✅,❌,❌,❌,✅
`OpenSearch`_,✅/✅,results/hits,✅,✅,✅,✅,❌,✅,✅,✅
`Oracle`_,✅/✅,results/hits,✅,❌,✅,✅,❌,❌,❌,✅
Expand Down Expand Up @@ -222,6 +223,76 @@ Here `test` is the name of database , `points` is the target collection name.
data: mongodb://localhost:27017/testdb
collection: testplaces


.. _MySQL:

MySQL
^^^^^

.. note::
Requires Python packages sqlalchemy, geoalchemy2 and pymysql

Must have MySQL installed.

.. code-block:: yaml

providers:
- type: feature
name: MySQL
data:
host: 127.0.0.1
port: 3306 # Default 3306 if not provided
dbname: test_geo_app
user: mysql
password: mysql
search_path: [test_geo_app] # Same as dbname
id_field: locationID
table: location
geom_field: locationCoordinates

A number of database connection options can be also configured in the provider in order to adjust properly the sqlalchemy engine client.
These are optional and if not specified, the default from the engine will be used. Please see also `SQLAlchemy docs <https://docs.sqlalchemy.org/en/14/core/engines.html#custom-dbapi-connect-arguments-on-connect-routines>`_.

.. code-block:: yaml

providers:
- type: feature
name: MySQL
data:
host: 127.0.0.1
port: 3306 # Default 3306 if not provided
dbname: test_geo_app
user: mysql
password: mysql
search_path: [test_geo_app] # Same as dbname
options:
# Maximum time to wait while connecting, in seconds.
connect_timeout: 10
# Number of *milliseconds* that transmitted data may remain
# unacknowledged before a connection is forcibly closed.
tcp_user_timeout: 10000
# Whether client-side TCP keepalives are used. 1 = use keepalives,
# 0 = don't use keepalives.
keepalives: 1
# Number of seconds of inactivity after which TCP should send a
# keepalive message to the server.
keepalives_idle: 5
# Number of TCP keepalives that can be lost before the client's
# connection to the server is considered dead.
keepalives_count: 5
# Number of seconds after which a TCP keepalive message that is not
# acknowledged by the server should be retransmitted.
keepalives_interval: 1
id_field: locationID
table: location
geom_field: locationCoordinates

This provider has support for the CQL queries as indicated in the Provider table above.

.. seealso::
:ref:`cql` for more details on how to use Common Query Language (CQL) to filter the collection with specific queries.


OGR
^^^

Expand Down
3 changes: 2 additions & 1 deletion pygeoapi/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@
'MVT-tippecanoe': 'pygeoapi.provider.mvt_tippecanoe.MVTTippecanoeProvider', # noqa: E501
'MVT-elastic': 'pygeoapi.provider.mvt_elastic.MVTElasticProvider',
'MVT-proxy': 'pygeoapi.provider.mvt_proxy.MVTProxyProvider',
'MySQL': 'pygeoapi.provider.sql.MySQLProvider',
'MVT-postgresql': 'pygeoapi.provider.mvt_postgresql.MVTPostgreSQLProvider', # noqa: E501
'OracleDB': 'pygeoapi.provider.oracle.OracleProvider',
'OGR': 'pygeoapi.provider.ogr.OGRProvider',
'OpenSearch': 'pygeoapi.provider.opensearch_.OpenSearchProvider',
'Parquet': 'pygeoapi.provider.parquet.ParquetProvider',
'PostgreSQL': 'pygeoapi.provider.postgresql.PostgreSQLProvider',
'PostgreSQL': 'pygeoapi.provider.sql.PostgreSQLProvider',
'rasterio': 'pygeoapi.provider.rasterio_.RasterioProvider',
'SensorThings': 'pygeoapi.provider.sensorthings.SensorThingsProvider',
'SensorThingsEDR': 'pygeoapi.provider.sensorthings_edr.SensorThingsEDRProvider', # noqa: E501
Expand Down
6 changes: 4 additions & 2 deletions pygeoapi/process/manager/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
ProcessorGenericError
)
from pygeoapi.process.manager.base import BaseManager
from pygeoapi.provider.postgresql import get_engine, get_table_model
from pygeoapi.provider.sql import get_engine, get_table_model
from pygeoapi.util import JobStatus


Expand Down Expand Up @@ -92,13 +92,15 @@ def __init__(self, manager_def: dict):
if isinstance(self.connection, str):
_url = make_url(self.connection)
self._engine = get_engine(
'postgresql+psycopg2',
_url.host,
_url.port,
_url.database,
_url.username,
_url.password)
else:
self._engine = get_engine(**self.connection)
self._engine = get_engine('postgresql+psycopg2',
**self.connection)
except Exception as err:
msg = 'Test connecting to DB failed'
LOGGER.error(f'{msg}: {err}')
Expand Down
2 changes: 1 addition & 1 deletion pygeoapi/provider/mvt_postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
TileSetMetadata, TileMatrixSetEnum, LinkType)
from pygeoapi.provider.base import ProviderConnectionError
from pygeoapi.provider.base_mvt import BaseMVTProvider
from pygeoapi.provider.postgresql import PostgreSQLProvider
from pygeoapi.provider.sql import PostgreSQLProvider
from pygeoapi.provider.tile import ProviderTileNotFoundError
from pygeoapi.util import url_join

Expand Down
Loading