def saveToPostGIS(self):
        dlg = PostgisTableSelector(self, self.parameter.name().lower())
        dlg.exec_()
        if dlg.connection:
            self.use_temporary = False
            settings = QgsSettings()
            mySettings = '/PostgreSQL/connections/' + dlg.connection
            dbname = settings.value(mySettings + '/database')
            user = settings.value(mySettings + '/username')
            host = settings.value(mySettings + '/host')
            port = settings.value(mySettings + '/port')
            password = settings.value(mySettings + '/password')
            uri = QgsDataSourceUri()
            uri.setConnection(host, str(port), dbname, user, password)
            uri.setDataSource(
                dlg.schema, dlg.table, "the_geom" if
                isinstance(self.parameter, QgsProcessingParameterFeatureSink)
                and self.parameter.hasGeometry() else None)

            connInfo = uri.connectionInfo()
            (success, user,
             passwd) = QgsCredentials.instance().get(connInfo, None, None)
            if success:
                QgsCredentials.instance().put(connInfo, user, passwd)
            self.leText.setText("postgis:" + uri.uri())

            self.skipOutputChanged.emit(False)
            self.destinationChanged.emit()
    def saveToPostGIS(self):
        dlg = PostgisTableSelector(self, self.parameter.name().lower())
        dlg.exec_()
        if dlg.connection:
            self.use_temporary = False
            settings = QgsSettings()
            mySettings = '/PostgreSQL/connections/' + dlg.connection
            dbname = settings.value(mySettings + '/database')
            user = settings.value(mySettings + '/username')
            host = settings.value(mySettings + '/host')
            port = settings.value(mySettings + '/port')
            password = settings.value(mySettings + '/password')
            uri = QgsDataSourceUri()
            uri.setConnection(host, str(port), dbname, user, password)
            uri.setDataSource(dlg.schema, dlg.table,
                              "the_geom" if isinstance(self.parameter, QgsProcessingParameterFeatureSink) and self.parameter.hasGeometry() else None)

            connInfo = uri.connectionInfo()
            (success, user, passwd) = QgsCredentials.instance().get(connInfo, None, None)
            if success:
                QgsCredentials.instance().put(connInfo, user, passwd)
            self.leText.setText("postgis:" + uri.uri())

            self.skipOutputChanged.emit(False)
            self.destinationChanged.emit()
 def saveToPostGIS(self):
     dlg = PostgisTableSelector(self, self.output.name.lower())
     dlg.exec_()
     if dlg.connection:
         settings = QSettings()
         mySettings = '/PostgreSQL/connections/' + dlg.connection
         dbname = settings.value(mySettings + '/database')
         user = settings.value(mySettings + '/username')
         host = settings.value(mySettings + '/host')
         port = settings.value(mySettings + '/port')
         password = settings.value(mySettings + '/password')
         uri = QgsDataSourceURI()
         uri.setConnection(host, str(port), dbname, user, password)
         uri.setDataSource(dlg.schema, dlg.table, "the_geom")
         connInfo = uri.connectionInfo()
         (success, user, passwd) = QgsCredentials.instance().get(connInfo, None, None)
         if success:
             QgsCredentials.instance().put(connInfo, user, passwd)
         self.leText.setText("postgis:" + uri.uri())
Beispiel #4
0
 def saveToPostGIS(self):
     dlg = PostgisTableSelector(self, self.output.name.lower())
     dlg.exec_()
     if dlg.connection:
         settings = QSettings()
         mySettings = '/PostgreSQL/connections/' + dlg.connection
         dbname = settings.value(mySettings + '/database')
         user = settings.value(mySettings + '/username')
         host = settings.value(mySettings + '/host')
         port = settings.value(mySettings + '/port')
         password = settings.value(mySettings + '/password')
         uri = QgsDataSourceURI()
         uri.setConnection(host, str(port), dbname, user, password)
         uri.setDataSource(dlg.schema, dlg.table, "the_geom")
         connInfo = uri.connectionInfo()
         (success, user,
          passwd) = QgsCredentials.instance().get(connInfo, None, None)
         if success:
             QgsCredentials.instance().put(connInfo, user, passwd)
         self.leText.setText("postgis:" + uri.uri())