How to add mdb geodatabase layer (feature class) to QGIS project using python?

المشرف العام

Administrator
طاقم الإدارة
I want to add a feature class of a personal geodatabase mdb to my qgs project by code (a plugin I am working on).

I am using a command similar to that used for adding shapefiles, but this is not working.I guess there must be a way, since it is possible to add the layer using the Add Vector Layer button.

This is the code i am using on the Python console:

mylayer = QgsVectorLayer("D:\Test\test.mdb\points", "mypoints", "ogr")QgsMapLayerRegistry.instance().addMapLayer(mylayer)The first line runs without error but the second one does not produce any result, contrary to the result is I do a similar command using a shapefile.

I am using QGIS 2.2 Valmiera 32 bits on Windows 7 64 bits. I did a previous research but I did not find any results!!! The feature class is not inside a feature dataset.

Thank you very much,

EDIT: I guess I would have to use a QgsDataSourceURI(), but i can not figure out the syntax. I have been trying. Also, I would also want to add that migrating the mdb is not an option, I have requested this before but my superiors have refused. And this geodatabase (points) is updated daily and huge. My goal after loading is clipping it based on a zone of interest.



أكثر...
 
أعلى