Is there a method to connect to an MS Access database file (.mdb) using QGIS?
In particular I need to connect to a query in it.
The database does not have spatial data.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityIs there a method to connect to an MS Access database file (.mdb) using QGIS?
In particular I need to connect to a query in it.
The database does not have spatial data.
It's possible to connect via ODBC.
... or directly with MS Access Forms ...
There is a sipmple way:
You are able to define a action for each Layer (see: Layerproperties) There you can input a pythonscript.
from win32com.client import Dispatch
dbname ="dbname.mdb"
dbForm = "frmname"
filter ='id= "[% "ID" %]"'
a=Dispatch("Access.Application")
a.Visible=True
objDB = a.CurrentDb()
if objDB is None:
a.OpenCurrentDatabase(dbname,True)
a.DoCmd.OpenForm(dbForm)
a.forms(dbForm).Filter = filter
a.forms(dbForm).FilterOn = True