Can you access joined tables through a da.SearchCursor?
I've found documentation to do this with SearchCursor (arcpy), but nothing for the 10.1 data access module.
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 community
I realized that the join in ArcMap does not persist in an arcpy session. So I needed to create the join in arcpy before accessing the table with a SearchCursor. A simple example:
import arcpy from sys import exc_info from traceback import format_tb exoticPath = r"...\Exotic_Species" protocolsPath=r"...\Treatment_Protocols" try: arcpy.MakeFeatureLayer_management(exoticPath,"exotic") arcpy.MakeTableView_management(protocolsPath,"protocols") arcpy.AddJoin_management("exotic","Species","protocols","CommonName") with arcpy.da.SearchCursor("exotic", ["Exotic_Species.Species","Treatment_Protocols.Priority"]) as cursor: for row in cursor: print (row, row) except: tb = exc_info() tbinfo = format_tb(tb) pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(exc_info()) msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n" arcpy.AddError(pymsg) arcpy.AddError(msgs) print pymsg + "\n" print msgs finally: if arcpy.Exists("exotic"): arcpy.Delete_management("exotic") if arcpy.Exists("protocols"): arcpy.Delete_management("protocols")
The arcpy.da.*Cursor are functionally equivalent to their arcpy.*Cursor counterpart... some additional niceties (context, more sql), and lots more speed. see doc for full details: http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000011000000
When writing new code, always use arcpy.da.Cursors. If you have critical code that uses old cursors, you may want to switch that code to new cursors.