Bug report #18515

QGIS 3.0 Can't Connect to PostgreSQL from DB Manager: PermissionError

Added by Raphael Dumas about 6 years ago. Updated almost 6 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Data Provider/PostGIS
Affected QGIS version:3.0.0 Regression?:No
Operating System:Windows 7 Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:26403

Description

Just installed and opened up 3.0.0-Girona. Connected to a `PostgreSQL 9.6.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-16), 64-bit` remote instance, was offered to store my credentials so I accepted. I can connected to the instance and see schemas.

I opened the DB Manager to open a SQL Window, when I click on SQL Window it says I'm not connected so I refresh connection:

WARNING    Traceback (most recent call last):
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\db_manager\db_model.py", line 441, in rowCount
                self._refreshIndex(parent, True)
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\db_manager\db_model.py", line 490, in _refreshIndex
                if item.populate():
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\db_manager\db_model.py", line 167, in populate
                if not connection.connect():
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\db_manager\db_plugins\postgis\plugin.py", line 103, in connect
                return self.connectToUri(uri)
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\db_manager\db_plugins\plugin.py", line 109, in connectToUri
                self.db = self.databasesFactory(self, uri)
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\db_manager\db_plugins\postgis\plugin.py", line 70, in databasesFactory
                return PGDatabase(connection, uri)
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\db_manager\db_plugins\postgis\plugin.py", line 111, in __init__
                Database.__init__(self, connection, uri)
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\db_manager\db_plugins\plugin.py", line 218, in __init__
                self.connector = self.connectorsFactory(uri)
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\db_manager\db_plugins\postgis\plugin.py", line 114, in connectorsFactory
                return PostGisDBConnector(uri)
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\db_manager\db_plugins\postgis\connector.py", line 128, in __init__
                os.remove(sslCAFile)
            PermissionError: [WinError 5] Access is denied: 'C:/Users/username/AppData/Local/Temp/tmp_basic_{alphanumeric_values}.pem'

Python version: 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] 
QGIS version: 3.0.0-Girona Girona, 001c80b0c3

Related issues

Duplicated by QGIS Application - Bug report #18775: Permission denied error when connecting to PostGIS DB wit... Closed 2018-04-20

History

#1 Updated by Raphael Dumas about 6 years ago

Just updated to 3.0.1 and this is still affected.

Interestingly this doesn't prevent loading layers from previous custom queries, but does prevent me from opening the SQL Window and loading new layers through that

#2 Updated by Jürgen Fischer about 6 years ago

  • Duplicated by Bug report #18775: Permission denied error when connecting to PostGIS DB with auth config using DB Manager added

#3 Updated by Jürgen Fischer about 6 years ago

  • Description updated (diff)
  • Subject changed from QGIS 3.0 Can't Connect to PostgreSQL from DB Manager: PremissionError to QGIS 3.0 Can't Connect to PostgreSQL from DB Manager: PermissionError

#4 Updated by Jürgen Fischer about 6 years ago

  • Description updated (diff)

#5 Updated by Jkr Da about 6 years ago

I have the same issue. Also the Toolbox -> Database -> Import into PostGIS function gives the same error.

2018-04-20T11:03:53    WARNING    Traceback (most recent call last):
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\processing\gui\ProcessingToolbox.py", line 333, in executeAlgorithm
                dlg = AlgorithmDialog(alg)
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\processing\gui\AlgorithmDialog.py", line 70, in __init__
                self.setMainWidget(self.getParametersPanel(alg, self))
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\processing\gui\AlgorithmDialog.py", line 77, in getParametersPanel
                return ParametersPanel(parent, alg)
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\processing\gui\ParametersPanel.py", line 82, in __init__
                self.initWidgets()
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\processing\gui\ParametersPanel.py", line 184, in initWidgets
                wrapper.postInitialize(list(self.wrappers.values()))
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\processing\gui\wrappers_postgis.py", line 94, in postInitialize
                self.setConnection(wrapper.value())
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\processing\gui\wrappers_postgis.py", line 108, in setConnection
                self._database = GeoDB.from_name(connection)
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\processing\tools\postgis.py", line 180, in from_name
                return cls(uri=uri)
              File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\processing\tools\postgis.py", line 242, in __init__
                os.remove(sslCAFile)
PermissionError: [WinError 5] Access is denied: 'C:/Users/username/AppData/Local/Temp/tmp_basic_{alphanumeric_values}.pem'

Windows 10. 3.0.1-Girona

#6 Updated by Raphael Dumas almost 6 years ago

Also affects `3.0.3-Girona`
QGIS code revision: 8a899c8758

#7 Updated by Raphael Dumas almost 6 years ago

  • Status changed from Open to Closed

The error in 3.0.3 appears to be different (I just updated to 3.2 and they are installed beside each other at the moment).

TypeError: unable to convert a QVariant of type 10 to a QMetaType of type 2 
Traceback (most recent call last):
  File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\db_manager\db_model.py", line 441, in rowCount
    self._refreshIndex(parent, True)
  File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\db_manager\db_model.py", line 490, in _refreshIndex
    if item.populate():
  File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./python/plugins\db_manager\db_model.py", line 167, in populate
    if not connection.connect():
  File "C:/PROGRA~1/QGIS3~1.0/apps/qgis/./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

Python version: 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] 
QGIS version: 3.0.3-Girona Girona, 8a899c8758

This is fixed in 3.2!

Also available in: Atom PDF