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/CSV_2_FeatureClass_2_DataStore.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\__init__.py", line 955, in __init__
self._portal = datastore._portal
AttributeError: 'str' object has no attribute '_portal'

 

UPDATE:

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')

 

current_file.manager.overwrite(current_file.manager.overwrite('AutomationExports.gdb/MetroBusStopsByLine_191021'))

 

and I am getting the following error

 

Traceback (most recent call last):
File "W:/Research&Development/Data-Share/layers/trapeze/MetroBusStops/AutomationExports/py/CSV_2_FeatureClass_2_DataStore.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\__init__.py", line 9509, in fromitem
if not item.type.lower().endswith('service'):
AttributeError: 'str' object has no attribute 'type'

Outcomes