Bug report #19240
Can't open PostGIS database in DBManager, QVariant error
|Affected QGIS version:||3.1(master)||Regression?:||Yes|
|Operating System:||Ubuntu||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||27068|
While I'm trying to connect to my PG database in the DB Manager:
An error has occurred while executing Python code: TypeError: unable to convert a QVariant of type 10 to a QMetaType of type 2 Traceback (most recent call last): File "/home/etienne/dev/qgis/build/master/output/python/plugins/db_manager/db_model.py", line 441, in rowCount self._refreshIndex(parent, True) File "/home/etienne/dev/qgis/build/master/output/python/plugins/db_manager/db_model.py", line 490, in _refreshIndex if item.populate(): File "/home/etienne/dev/qgis/build/master/output/python/plugins/db_manager/db_model.py", line 167, in populate if not connection.connect(): File "/home/etienne/dev/qgis/build/master/output/python/plugins/db_manager/db_plugins/postgis/plugin.py", line 88, in connect sslmode = settings.value("sslmode", QgsDataSourceUri.SslPrefer, type=int) TypeError: unable to convert a QVariant of type 10 to a QMetaType of type 2
I couldn't expand it in the tree view (see tables, execute queries etc...)
I got this error on 2 computers with 2 different databases so it might happen to someone else.
I fixed it by going into QGIS Settings, Advanced, and then "PostgreSQL/connections/my_connection/sslmode" = 1, it was previously a string like "SslDisable". I'm not sure how I got a string instead of integer. Now I can open again the DB Manager.