0

I was testing my script on a .gdb on my local drive and I got it to work. The actual geodatabase I would like to run the script on is an SDE. I tried changing my filepath from the .gdb to the .sde and it failed. Can someone help me figure out how to configure my script so that it will work on the SDE?

#import system module 
import arcpy, os
#define filepath
filepath = r"C:\Users\kkaszas\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\SANGeodatabase.sde"
arcpy.env.workspace = filepath
#enable overwrite 
arcpy.env.overwriteOutput = True
fcList = arcpy.ListFeatureClasses()
fieldName1 = "Author"
fieldName2 = "LastUpdated"
expression1 = "\"John Doe\""
expression2 = 20121011
for fc in fcList:
 arcpy.AddField_management(fc,fieldName1, "TEXT")
 arcpy.AddField_management(fc,fieldName2, "LONG")
 print "fields added to " + fc
 arcpy.CalculateField_management(fc, fieldName1, expression1, "PYTHON")
 arcpy.CalculateField_management(fc, fieldName2, expression2,"PYTHON")
 print "Fields have been calculated for " + fc
asked Oct 11, 2012 at 23:29
8
  • 2
    Can you post the error message you're getting? Commented Oct 11, 2012 at 23:33
  • I am not getting an error, when I run the scrip the shell returns two blank lines. Commented Oct 11, 2012 at 23:35
  • Ohhh, so it sounds like its "completing" the script. Try putting some AddMessages in to print the "fc" or the "fclist". The ListFeatureClass function should work against the SDE workspace... Commented Oct 11, 2012 at 23:43
  • Also, what database backend is your SDE running on? Commented Oct 11, 2012 at 23:50
  • Its running on a SQL Express database. Commented Oct 11, 2012 at 23:55

1 Answer 1

2

Set your arcpy.env.workspace to "Database Connections\\\nameofdatabase.sde\\\" or

arcpy.env.workspace = "Database Connections\\\nameofdatabase.sde\\\"

Hope that helps.

urcm
22.6k4 gold badges59 silver badges109 bronze badges
answered Oct 16, 2012 at 20:58

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.