Bug report #16705

Updated by Jürgen Fischer about 7 years ago

If a PostgreSQL database doesn't have PostGIS installed or configured properly, the database manager errors out without specific indications what's wrong (at least to a novice postgres user as myself). In my case I had installed the postgis extension (in a separate schema), and configured the search_path to include it. I could connect to the database in "Add PostGIS layers" and in the Browser Panel, and see the schemas I had access to, but in the database manager manger I only got some errors (see below). It turns out I had followed a mistaken snippet for configuring the search_path (assigned a string instead of a list of schemas), so PostGIS was actually not available on the search_path.

I think from a user perspective, two things would be helpful:
1) Add a check for PostGIS, and a warning if the extension is missing, and display this in the "Add PostGIS Table(s)" dialog, the Browser Panel, and the Database Manager.
2) Make the Database Manager behave like the "Add PostGIS Table" and Browser Panel, so show the schemas and tables you have access to even if PostGIS is missing (plus the warning).

The errors (stacktrace):

@An error has occurred while executing Python code:

TypeError: 'NoneType' object has no attribute '__getitem__'
Traceback (most recent call last):
File "C:/OSGEO4~1/apps/qgis/./python/plugins\db_manager\db_model.py", line 438, in rowCount
self._refreshIndex(parent, True)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\db_manager\db_model.py", line 489, in _refreshIndex
if item.populate():
File "C:/OSGEO4~1/apps/qgis/./python/plugins\db_manager\db_model.py", line 164, in populate
if not connection.connect():
File "C:/OSGEO4~1/apps/qgis/./python/plugins\db_manager\db_plugins\postgis\plugin.py", line 96, in connect
return self.connectToUri(uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\db_manager\db_plugins\plugin.py", line 106, in connectToUri
self.db = self.databasesFactory(self, uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\db_manager\db_plugins\postgis\plugin.py", line 66, in databasesFactory
return PGDatabase(connection, uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\db_manager\db_plugins\postgis\plugin.py", line 104, in __init__
Database.__init__(self, connection, uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\db_manager\db_plugins\plugin.py", line 215, in __init__
self.connector = self.connectorsFactory(uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\db_manager\db_plugins\postgis\plugin.py", line 107, in connectorsFactory
return PostGisDBConnector(uri)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\db_manager\db_plugins\postgis\connector.py", line 134, in __init__
self._checkGeometryColumnsTable()
File "C:/OSGEO4~1/apps/qgis/./python/plugins\db_manager\db_plugins\postgis\connector.py", line 167, in _checkGeometryColumnsTable
self.has_geometry_columns_access = priv[0]
TypeError: 'NoneType' object has no attribute '__getitem__'@

Back