3

I have a model that copies a single F.C form SDE geodatabase to a scratch geodatabase then copies it back with a new name to the same SDE geodatabase again. And this works perfectly form the model. Now I have exported the model to python script, but unfortunately it doesn’t work and I didn’t figure out what is the problem.

enter image description here

Here is the Result python code

    # Import arcpy module
import arcpy


# Local variables:
Points_DBO_Communities = "Database Connections\\1.sde\\Points.DBO.Communities"
Buildings_POINTS_Select = "C:\\Users\\ahmads\\Documents\\ArcGIS\\Default.gdb\\Buildings_POINTS_Select"
Points_DBO_Buildings_POINTS1 = "Database Connections\\1.sde\\Points.DBO.Buildings_POINTS1"

# Process: Select
arcpy.Select_analysis(Points_DBO_Communities, Buildings_POINTS_Select, "")

# Process: Copy Features
arcpy.CopyFeatures_management(Buildings_POINTS_Select, Points_DBO_Buildings_POINTS1, "", "0", "0", "0")

Now Trying to run the code and I got this massage :

"arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Table: Dataset C:\Users\jamaln\Documents\ArcGIS\Default.gdb\ UrbanMasterPlans_Objection_S2 does not exist or is not supported Failed to execute (AddField)"

enter image description here

What might be the issue here ?

  • 2
    Whenever presenting error messages please include them as text rather than pictures so that they can be available to future searches. – PolyGeo Apr 26 '15 at 8:20
3

You run your model from ArcMap which is aware of the Database Connections folder present in Catalog window. However when you execute your code in an external Python file, the arcpy cannot find the Database Connections. You need to supply the .sde connection file stored somewhere on your disk.

I always recommend use an .sde file even in models. You can find the connection files at C:\Users\%user%\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog and then copy them somewhere else.

I also see that you get an error while trying to overwrite an existing feature class. You can if arcpy.Exists() logic to check whether the object exists and delete it first. Otherwise, use the arcpy.env.overwriteOutput = True.

  • thanks Alex, after copying my SDE form C:\Users\%user%\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog to D:\ it worked with me – Ahmad saleh Apr 27 '15 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.