AnsweredAssumed Answered

Updating enterprise feature class using ArcGIS API for Python

Question asked by WKJenkins_METROSTL on Oct 22, 2019
Latest reply on Oct 24, 2019 by WKJenkins_METROSTL

I have created a Python script that will turn some CSVs to features in a GDB and I am trying to get the feature class on my local machine to overwrite the feature on our enterprise portal. I have imported the arcgis.gis library and I think that I need to be using the arcgis.gis.Datastore().update.

   gis = ag.GIS(portal, user, password)
   print(f'Connected to {portal}')
   print(ag.Datastore('ArcGIS_Data_Store', '\\portal-url\arcgisdatastore)').datasets)

It seems like I am getting logged in alright, but when I run this script I get the following error. I am unable to find any examples for this. How do others update their files in the datastore.


Traceback (most recent call last):
Connected to https://portal-url/arcgis/
File "W:/Research&Development/Data-Share/layers/trapeze/MetroBusStops/AutomationExports/py/", line 65, in <module>
print(ag.Datastore(datastore='ArcGIS_Data_Store', path='https://portal-url/arcgis/arcgisdatastore').datasets)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\", line 955, in __init__
self._portal = datastore._portal
AttributeError: 'str' object has no attribute '_portal'



I have started using the FeatureLayerCollection module. I have imported at the top and have appended the following


current_file = FeatureLayerCollection.fromitem.fromitem('https://url/arcserver/rest/services/MetroBusStopsByLine_191021/MapServer/0')




and I am getting the following error


Traceback (most recent call last):
File "W:/Research&Development/Data-Share/layers/trapeze/MetroBusStops/AutomationExports/py/", line 69, in <module>
current_file = FeatureLayerCollection.fromitem('https://url/arcserver/rest/services/MetroBusStopsByLine_191021/MapServer/0')
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\", line 9509, in fromitem
if not item.type.lower().endswith('service'):
AttributeError: 'str' object has no attribute 'type'