I'm working on integrating QGIS and PostGIS, but looking for a way to force a layer reload. I don't need it to be automated -- I'm happy to run a command every time I want to refresh the map. The comments on this question:
How to refresh the attribute table of a layer after editing the table in the DB-Manager?
Suggest that layer.dataProvider().forceReload(); is one option, but when I open Plugins > Python Console and run that I get an error:
layer.dataProvider().forceReload();
Traceback (most recent call last):
File "<input>", line 1, in <module>
NameError: name 'layer' is not defined
I thought maybe I needed to use the name of my layer, but that didn't fix it:
example.dataProvider().forceReload();
Traceback (most recent call last):
File "<input>", line 1, in <module>
NameError: name 'example' is not defined
Am I misunderstanding that suggestion? Is there another way to accomplish this in the python console?
layer = QgsMapLayerRegistry.instance().mapLayersByName("YOUR_LAYER_NAME")... – Snaileater Apr 02 '18 at 06:53