I am trying to use arcpy cursors on a hosted feature layer containing a geodatabase with multiple tables and feature classes. After digging around the internet, a few posts seem to allude that I can do this:
https://gis.stackexchange.com/questions/363932/how-can-i-use-updatecursor-in-agol-layers
https://community.esri.com/t5/arcgis-api-for-python-questions/updatecursor-with-a-hosted-table/td-p/781002
Whereby, it seems the process is to:
- Access ArcGIS Online account
- Search for the hosted feature layer in my content
- Use the URL for the item as the first parameter in the arcpy cursor (i.e. arcpy.da.SearchCursor(item.url, fields))
- Run Cursor
So, code looks something like this:
from arcgis.gis import GIS
import arcpy
gis = GIS("https://www.arcgis.com", "username", "password")
hfl = gis.content.get('itemitd')
url = hfl.tables[8]
with arcpy.da.SearchCursor(url, '*') as cursor:
for row in cursor:
print(row)
Which returns the following error:
RuntimeError: cannot open 'https://services6.arcgis.com/yadda/arcgis/rest/services/nameofhostedfeaturelayer/FeatureServer/10'
I tried using a slightly different approach to grab the item, but is pretty much the same as the above:
hfl = gis.content.search(query="title:nameofhostedfeaturelayer, owner:username", max_items=1000)
url = hfl[0].tables[8].url
with arcpy.da.UpdateCursor(url , "*") as cursor:
for row in cursor:
row[0] = "hello"
cursor.updateRow(row)
Which yields the same error.
Couple notes:
- I own the data
- It is shared to a few groups, but not publicly
- I've allowed edits on the hosted feature layer and any other setting that may or may not allow the script to see and read the hosted feature layer
- It appears I do have access to the hosted feature layer and I can perform other operations on it such as printing out items or values:
for v in hfl.values():
print(o)
for i in hfl.items():
print(c)
Any suggestions why I am receiving that error?