0

Why is QGIS not refreshing after updating a connected database?

It is a MS Access Database which I connected to QGIS using ODBC. The database contains coordinates of some vessels and they are already visible in QGIS but it is only refreshing when I disconnect and then reconnect the db connection. I am looking for a solution the past few days but I am not possible to find any.

3
  • I think QGIS uses ogr2ogr to connect to different datasources. I'd guess that polling all the different providers for changes would be impractical. See docs.qgis.org/3.4/en/docs/user_manual/working_with_vector/… for docs. You can look at the source here: github.com/qgis/QGIS/tree/master/src/core/providers/ogr
    – vinh
    Commented Sep 12, 2019 at 15:17
  • Thanks but i couldnt find anything. I cannot believe that it is so hard to update the QGIS project without disconnecting the database....
    – Dave
    Commented Sep 18, 2019 at 13:18
  • hey can you pls lemme know how yo displayed data from acess database on qgis ...i am not able to do so Commented Apr 9, 2020 at 5:53

2 Answers 2

1

I don't use ODBC actively so this is a bit of a stab in the dark.

With the recalcitrant layer selected, go to the Python console (Ctrl-Alt-P) in QGIS, and try entering the following

iface.activeLayer().dataProvider().forceReload()

This should force the dataprovider (OGR) to reload the data, which I hope should force it to actually go to the underlying (updated) data in Access.

If this does work, then there are ways (using Python startup code in your userprofile or in the project) this could e.g. be bound to a keyboard shortcut, so you could do it whenever needed without having to open the Python console.

1

I use QGIS to access Filemaker databases via ODBC (also to map vessel data). I find that it will refresh with new data when QGIS is forced to re-draw, by either zooming or panning the map.

I recently detailed how the QGIS-ODBC-Filemaker connection is made here, and the same principles should also apply to Access:

Filemaker Interface with QGIS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.