Skip to main content
Question

Python TruncateTable_management not working with getAttribute list

  • May 4, 2020
  • 2 replies
  • 55 views

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)

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • 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
  • 6 replies
  • 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})

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