Example #1
0
def pg_layerNamesIDMapping():
    '''
    Returns a dictionary containing the original table names and corresponding layer IDs in the
    QGIS legend for only those layers from a postgres database.
    '''
    mapping = ReverseDict()
    layers = QgsMapLayerRegistry.instance().mapLayers()

    for name, layer in layers.iteritems():
        if layer.dataProvider().name() == 'postgres':
            layerConnStr = layer.dataProvider().dataSourceUri()
            dataSourceURI = QgsDataSourceURI(layerConnStr)
            mapping[dataSourceURI.table()] = layer.id()

    return mapping
 def clear(self):
     """
     Clears the data source name and removes all data field mappings.
     """
     self._dataSourceName = ""
     self._dataFieldmappings = ReverseDict()
 def __init__(self,dataSourceName="",category = ""):
     self._dataSourceName = dataSourceName
     self._dataSourceCategory = category
     self._dataFieldmappings = ReverseDict()
     self._spatialFieldsConfig = None