I can access ESRI .GDB data using OSGeo's OGR. The following code gives feature class names embedded in .GDB...

from osgeo import ogr

driver = ogr.GetDriverByName("FileGDB")
data = driver.Open(r"D:\pycharm_development\turkiye_db.gdb", 0)

feature_class_list = []

for i in data:
    foo = i.GetName()

print feature_class_list

But I cannot access ESRI .GDB data in PyQGIS environment, unfortunately. PyQGIS works properly in my PC and .SHP files can be loaded successfully...

Is QgsVectorLayer() approach true or should QgsDataSourceURI() class be used to handle that?

P.S. I installed from OSGeo4W 64-bit installer. I'm using PyCharm IDE.

  • Please edit your question to include how/from where you installed both gdal/ogr, and QGIS.
    – user2856
    Dec 21, 2014 at 11:27
  • Please post the solution as a separate answer and remove the SOLVED from the question title for consistency with the site format.
    – ako
    Dec 22, 2014 at 19:25

1 Answer 1


QgsVectorLayer() approach is true. Here is the code which can read field names of a specific feature class in ESRI .GDB:

from qgis.core import *

QgsApplication.setPrefixPath("D:/OSGeo4W64/apps/qgis", True)

layer = QgsVectorLayer("D:/pycharm/turkiye_db.gdb|layername=tr_il", "provinces", "ogr")

fields = layer.pendingFields()

for i in range(fields.count()):
    field = fields[i]
    print "Name:%s" % (field.name())

Your Answer

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

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