Skip to content

Commit

Permalink
feat(ingest): support Postgres PostGIS extensions (#2136)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsheth2 authored Feb 25, 2021
1 parent e6f7f39 commit 656d9c7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions metadata-ingestion/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ Extracts:

Extra requirements: `pip install psycopg2-binary` or `pip install psycopg2`

If you're using PostGIS extensions for Postgres, also use `pip install GeoAlchemy2`.

```yml
source:
type: postgres
Expand Down
2 changes: 2 additions & 0 deletions metadata-ingestion/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ ignore_missing_imports = yes
ignore_missing_imports = yes
[mypy-ldap.*]
ignore_missing_imports = yes
[mypy-geoalchemy2.*]
ignore_missing_imports = yes

[isort]
profile = black
Expand Down
10 changes: 10 additions & 0 deletions metadata-ingestion/src/datahub/ingestion/source/postgres.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
from .sql_common import BasicSQLAlchemyConfig, SQLAlchemySource

try:
# GeoAlchemy adds support for PostGIS extensions in SQLAlchemy. In order to
# activate it, we must import it so that it can hook into SQLAlchemy. While
# we don't use the Geometry type that we import, we do care about the side
# effects of the import. For more details, see here:
# https://geoalchemy-2.readthedocs.io/en/latest/core_tutorial.html#reflecting-tables.
from geoalchemy2 import Geometry # noqa
except ImportError:
pass


class PostgresConfig(BasicSQLAlchemyConfig):
# defaults
Expand Down

0 comments on commit 656d9c7

Please sign in to comment.