Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
Can you post the error message you're getting? – KHibma Oct 11 '12 at 23:33
I am not getting an error, when I run the scrip the shell returns two blank lines. – kkaszas Oct 11 '12 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 Oct 11 '12 at 23:43
Also, what database backend is your SDE running on? – om_henners Oct 11 '12 at 23:50
Its running on a SQL Express database. – kkaszas Oct 11 '12 at 23:55

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

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

Hope that helps.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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