Skip to content

Add a database table (PostGIS or Oracle Spatial)

A PostGIS or Oracle Spatial table can be added via the plugin under the following conditions:

Several similar connections

If several connections have been configured for databases with identical names, it is possible totell the plugin which connection to use to access data stored in the database concerned.

Connection configured in QGIS data source manager

By entering password and user name and choosing to store them (for Oracle and PostGIS databases):

For PostgreSQL databases only

You can enter the name of a service in the"Service" field of the form used to create a new database connection (see screenshot above).

This service must have been specified in a pg_service.conf configuration file.

The location of the pg_service.conf file must have been saved in a "PGSERVICEFILE" environment variable configured in the OS and in QGIS ("Preferences" menu >"Options..." > "System" tab > "Environment" heading > "+" button) >"System" tab >"Environment" section > "+" button).

Connection configured in the db_connections.json file in the _user folder

Location of db_connections.json file
C:\Users\%userprofile%\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\isogeo_search_engine\_user\db_connections.json
/home/%userprofile%/.local/share/QGIS/QGIS3/profiles/default/python/plugins/isogeo_search_engine/_user/db_connections.json

By entering the connection information in the _user/db_connections.json file in the QGIS Isogeo plugin installation directory.

Examples of _user/db_connections.json file contents

Configuring a single connection to a PostgreSQL database :

{
    "Oracle" : [],
    "PostgreSQL" : [
        {
            "connection_name" : "Nom de la connexion (il doit être unique)",
            "host" : "hôte",
            "port" : "port", 
            "database" : "nom de la base de données",
            "username" : "nom d'utilisateur",
            "password" : "mot de passe de l'utilisateur"
        }
    ]
}

Configure 2 connections to PostgreSQL databases and 1 connection to an Oracle database:

{
    "Oracle" : [
        {
            "connection_name" : "Nom de la connexion (il doit être unique)",
            "host" : "hôte",
            "port" : "port", 
            "database" : "nom de la base de données",
            "username" : "nom d'utilisateur",
            "password" : "mot de passe de l'utilisateur"
        }
    ],
    "PostgreSQL" : [
        {
            "connection_name" : "Nom de la connexion (il doit être unique)",
            "host" : "hôte",
            "port" : "port", 
            "database" : "nom de la base de données",
            "username" : "nom d'utilisateur",
            "password" : "mot de passe de l'utilisateur"
        },
        {
            "connection_name" : "Nom de la connexion (il doit être unique)",
            "host" : "hôte",
            "port" : "port", 
            "database" : "nom de la base de données",
            "username" : "nom d'utilisateur",
            "password" : "mot de passe de l'utilisateur"
        }
    ]
}

In the case of Oracle databases, it is sometimes necessary to add a database_alias entry. When the value of the "Resource location" field in the metadata record is different from the database name, the database_alias entry must be filled in with the value of the"Resource location" field in the metadata record.

{
    "Oracle" : [
        {
            "connection_name" : "Nom de la connexion (il doit être unique)",
            "host" : "hôte",
            "port" : "port", 
            "database" : "nom de la base de données",
            "database_alias" : "emplacement de la ressource",
            "username" : "nom d'utilisateur",
            "password" : "mot de passe de l'utilisateur"
        }
    ],
    "PostgreSQL" : []
}

Check the contents of the _user/db_connections.json file

If this option doesn't seem to work, take a moment to check that the file has been populated with valid information. You can also use this site (or an equivalent) to check that the content of the JSON file conforms to the specifications.