I've been using ArcPy for quite a while, but I'm now trying to learn how to create geospatial workflows using PyQGIS. I'm starting with simple things, like adding a layer to the map. I'm trying with the following code:
import os
gdb_URL = r'...'
fc_path = os.path.join(gdb_URL, 'feature_class')
layer = iface.addVectorLayer(fc_path, 'layer_name','ogr')
That throws a message saying that 'the layer is not valid'.
=> If I use the same piece of code to add a shapefile instead of a feature class within a file geodatabase, the layer gets added without problems.
=> If I try to add the feature class within a file geodatabase using the "Open Data Source Manager" button in QGIS, the feature class gets added without problems.
Any ideas why that piece of code is not valid to add feature classes?
Maybe 'ogr' is wrong and I should be using a different provider name.