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
-
2Can you post the error message you're getting?KHibma– KHibma2012年10月11日 23:33:22 +00:00Commented Oct 11, 2012 at 23:33
-
I am not getting an error, when I run the scrip the shell returns two blank lines.kkaszas– kkaszas2012年10月11日 23:35:40 +00:00Commented 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...KHibma– KHibma2012年10月11日 23:43:22 +00:00Commented Oct 11, 2012 at 23:43
-
Also, what database backend is your SDE running on?om_henners– om_henners2012年10月11日 23:50:43 +00:00Commented Oct 11, 2012 at 23:50
-
Its running on a SQL Express database.kkaszas– kkaszas2012年10月11日 23:55:32 +00:00Commented Oct 11, 2012 at 23:55
1 Answer 1
Set your arcpy.env.workspace
to "Database Connections\\\nameofdatabase.sde\\\"
or
arcpy.env.workspace = "Database Connections\\\nameofdatabase.sde\\\"
Hope that helps.
Explore related questions
See similar questions with these tags.