AnsweredAssumed Answered

Errors in standalone script when copying Route Event Layer to fgb

Question asked by jtrudnak on Jul 23, 2020
Latest reply on Sep 1, 2020 by jtrudnak

I am working on a standalone python script that dissolves speed data across a network to perform a daily refresh a table in our enterprise geodatabase.  I've made the script work several ways when running in the ArcCatalog python window.  I am running into errors when trying to run as a standalone script.  Pretty much generic error codes as noted in the abbreviated script below.  I've tried specifying the event route layer be written to the current workspace and  scratch workspace.   Any suggestions?   Working in 10.7.1.  32 bit execution in catalog and stand alone. Relatively new to python.  Thanks.


import arcpy
arcpy.env.overwriteOutput = True

db_connect = r"Database Connections//GIS on GISD.sde"
arcpy.env.workspace = r'\\GIS_SEVER\Workspace\Speeds_Dissolve\Speeds_Working.gdb'
arcpy.env.scratchWorkspace = r'\\GIS_SERVER\Workspace\Speeds_Dissolve\Scratch.gdb'
outFGB = r'\\GIS_SERVER\Workspace\Speeds_Dissolve\Speeds_Working.gdb'
scratchFGB = r'\\GIS_SERVER\Workspace\Speeds_Dissolve\Scratch.gdb'
ToTable = db_connect + "\GDP_OWN.O_SPEED_SEGMENT_DIS"

#define tables
#multiple tables
speed_dis = outFGB + "\speed_dis"
speed_lrs_dis_lines = outFGB + "\speed_lrs_dis_lines"
speed_mrel = scratchFGB + "\speed_mrel"

#step - clean up data from previous run if exists - successfully completes
#step - use query layer to export LRS layer to fgb (mp_detail_lrs)  - successfully completes
#step - user query layer to export speed data to table - successfully completes
#step - define fields name for speeds, MakeTableView, and save to fgb - successfully completes
#step - DissolveRouteEvents_lr using table from previous step, speed_dis - successfully completes


#step - MakeRouteEventLayer - successfully completes
arcpy.MakeRouteEventLayer_lr(mp_detail_lrs,"ROUTE_I", speed_dis, props,speed_mrel,"#","ERROR_FIELD")
result4 = arcpy.GetCount_management(speed_mrel)
print ("Speed QL (speed_mrel) record count:" + str(result4)) #returns count successfully

#step - export/copy Route event layer to fgb - NOT SUCCESSFUL as standalone

#option1 - arcpy.CopyFeatures_management(speed_mrel,speed_lrs_dis_lines)
##--line 2568, in CopyFeatures raise ERROR 999998: Unexpected Error.Failed to execute (CopyFeatures)


##option 2 - ArcGIS\Desktop10.7\ArcPy\arcpy\", line 18093, in CopyRows -- ERROR 999998: Unexpected Error.


#option 3 - arcpy.Append_management(speed_mrel, speed_lrs_dis_lines,"NO_TEST")
##Traceback (most recent call last):
##File "Q:\Speeds_Dissolve\", line 186, in <module>
##arcpy.Append_management(speed_mrel, speed_lrs_dis_lines,"NO_TEST")
##File "C:\Program Files (x86)\ArcGIS\Desktop10.7\ArcPy\arcpy\", line 4256, in Append
##raise e ExecuteError: ERROR 999998: Unexpected Error. Failed to execute (Append).


#option 4 - Attempting cursor, no error message, no records inserted into fgb table
dsc = arcpy.Describe(speed_mrel) #route event layer
fields = dsc.fields
fieldnames = [ for field in fields if != dsc.OIDFieldName and != 'SHAPE.LEN' and != 'Shape']
print (fieldnames) #expected fields are returned
query = "select * from speed_mrel"
with arcpy.da.SearchCursor(speed_mrel, fieldnames,query)as sCur1:
with arcpy.da.InsertCursor(speed_lrs_dis_lines,fieldnames) as iCur1:
for row in sCur1:
printf = row.getValue(Field1)
print (printf)