Skip to main content
Question

Python TruncateTable_management not working with getAttribute list


I am trying to run a python script in a PythonCaller to Truncate Features in an Oracle ArcSDE database.

If I run the script and hard code the Feature it runs fine but when I try to use feature.getAttribute to read a list created in a previous transformer, I keep getting:

Python Exception <ExecuteError>: Failed to execute. Parameters are not valid.

ERROR 000187: Only supports Geodatabase tables and feature classes

 

My script is:

# Import arcpy module

import arcpy

 

def processFeature(feature):

IFeatures = ('C:\\\\AppData\\\\Roaming\\\\ESRI\\\\Desktop10.5\\\\ArcCatalog\\\\Connection_to_HYDRA.sde\\\\' + feature.getAttribute('_list{0}'))

 

print (IFeatures)

for mark in IFeatures:

arcpy.TruncateTable_management(mark)

2 replies

ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • May 4, 2020

I don't have access to arcpy right now so i'm not 100% sure on setting the environment for sde but normally I'd expect the code to look something like this

 

import arcpy

def processFeature(feature):

    arcpy.env.workspace = "C:\\AppData\\Roaming\\ESRI\\Desktop10.5\\ArcCatalog\\Connection_to_HYDRA.sde"

    IFeatures = feature.getAttribute('_list{}')

    for mark in IFeatures:

        arcpy.TruncateTable_management(mark)

So set the environment, and then get the list (I'm presuming you want all list items, as your posted code only references the first list item (_list{0})


  • Author
  • May 4, 2020
ebygomm wrote:

I don't have access to arcpy right now so i'm not 100% sure on setting the environment for sde but normally I'd expect the code to look something like this

 

import arcpy

def processFeature(feature):

    arcpy.env.workspace = "C:\\AppData\\Roaming\\ESRI\\Desktop10.5\\ArcCatalog\\Connection_to_HYDRA.sde"

    IFeatures = feature.getAttribute('_list{}')

    for mark in IFeatures:

        arcpy.TruncateTable_management(mark)

So set the environment, and then get the list (I'm presuming you want all list items, as your posted code only references the first list item (_list{0})

Thanks @ebygomm, that did the job.  I did want all the list items as well. 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings