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

Your Answer

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

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