arcpy.SearchCursor and a query Layer

1184
2
08-13-2014 06:35 AM
JohnByrne
New Contributor

Hi all,

We have developed that a python script that will allow us to search a FGDb however once we put it onto the server and use it against a Query Feature Class (a view containing a query from several tables) then it fails as it doesnt like the data source.

When we hard coded the connection path it states that the expression is empty!!!

Please find the code below, any ideas on a SearchCursor within arcpy that can search a query layer?? Like I said, we know the code works it's just this one thing that is failing on the new environment

  cursor = arcpy.SearchCursor(fieldsLyr.dataSource, where_clause=ddp_field + " = '" + busid + "'", fields="MIA_BY_CATEGORY")


Any help is always appreciated,

Thanks

0 Kudos
2 Replies
RiyasDeen
Occasional Contributor III

arcpy.da.SearchCursor (not same as arcpy.SearchCursor) ArcGIS Help 10.1‌, Input does't have to be a feature class or table, it can be a layer or table.

0 Kudos
ToddUlery
Occasional Contributor

Hi John, the preferred is no the da.SearchCursor, but that is probably not the issue.

Can you add a bit more information for us to look at.

SearchCursor (dataset, {where_clause}, {spatial_reference}, {fields}, {sort_fields})

Can you provide the dataset parameter:

fieldsLry came from where, and did you provide yourself access to the objects.datasource attribute?

Also, when you have parameters that are not being filled out, just helpful to place ""  for empty. Just a practice I do, just to make sure. Particularly with the old SearchCursor.

0 Kudos