dicogis.georeaders.read_postgis module

class dicogis.georeaders.read_postgis.ReadPostGIS(host=None, port=None, db_name=None, user=None, password=None, service=None, views_included=True)

Bases: GeoReaderBase

Read PostGIS database.

__init__(host=None, port=None, db_name=None, user=None, password=None, service=None, views_included=True)
Uses OGR to extract basic informations about geodata stored into a PostGIS

database.

Parameters:
  • txt (dict) – dictionary of translated texts

  • host (str, optional) – postgres connection host. Defaults to “localhost”.

  • port (int, optional) – postgres connection port. Defaults to 5432.

  • db_name (str, optional) – postgres database name. Defaults to “postgis”.

  • user (str, optional) – postgres connection user name. Defaults to “postgres”.

  • password (str, optional) – postgres connection user password. Defaults to “postgres”.

  • service (Optional[str], optional) – name of pg_service to use to connect to the database. If defined, other connection parameters are ignored. Defaults to None.

  • views_included (bool, optional) – option to include views. Defaults to True.

get_connection()

Open a connection to the PostgreSQL database using GDAL.

Returns:

OGR connection

Return type:

Optional[ogr.DataSource]

get_postgis_version()

Returns the version of PostGIS extension.

Returns:

PostGIS version

Return type:

Optional[str]

get_schemas()

Return unique set of schemas names accessible by the logged user.

Returns:

set of schemas names

Return type:

set[str]

infos_dataset(layer, metadataset=None)

Extract metadata from PostGIS layer and store it into the dictionary.

Parameters:
  • layer (ogr.Layer) – input PostGIS layer

  • dico_dataset (Optional[dict], optional) – dictionary to fill with extracted data. Defaults to None.

Return type:

Optional[MetaDatabaseTable]