Bug report #19240

Can't open PostGIS database in DBManager, QVariant error

Added by Etienne Trimaille almost 6 years ago. Updated almost 6 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:DB Manager
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

Description

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.

Associated revisions

Revision 12efb866
Added by Nyall Dawson almost 6 years ago

[dbmanager] Fix error when connecting to postgis db

Fixes #19240

History

#1 Updated by Nyall Dawson almost 6 years ago

  • % Done changed from 0 to 100
  • Status changed from Open to Closed

Also available in: Atom PDF