FIXED THE SCRIPT COPY/PASTE below:
HI all -
Maybe you can help me out.
I've been getting this error for ages and it is making me nuts:
Here's the script:
# Move points based up current lat/lon #grab stuff you need import arcpy, os # Set variables folderName = r"S:\AGR\AGR-Shared\AGR-GIS\AGR_Data" fileName = "Connection to cloud.agriculture.vermont.gov.sde" filepath = r'S:\AGR\AGR-Shared\AGR-GIS\AGR_Data\Connection to cloud.agriculture.vermont.gov.sde' serverName = "agr-ofwq2012\AGRGIS" serviceName = "5151" databaseName = "AGRGISDATA" authType = "DATABASE_AUTH" username = "**********" password = "**********" saveUserInfo = "SAVE_USERNAME" versionName = "SDE.DEFAULT" saveVersionInfo = "SAVE_VERSION" # Process: Use the CreateArcSDEConnectionFile function arcpy.CreateDatabaseConnection_management(folderName, fileName, "SQL_SERVER", serverName, authType, username, password, saveUserInfo, databaseName) fc = "AGRGISDATA.DBO.ApiariesWGS" print fc fc_path = os.path.join(filepath, fc) print fc_path fields = ['Longtitude','Latitude','SHAPE@XY'] print fields arcpy.env.workspace = filepath workspace = os.path.dirname(filepath) print workspace editor = arcpy.da.Editor(workspace) print editor editor.startEditing(False, False) editor.startOperation() #create curser on fc try: with arcpy.da.UpdateCursor(fc,fields) as cursor: for row in cursor: x = row y = row xy = (x,y) pnt = xy row = pnt cursor.updateRow(row) finally: editor.stopEditing(True) del editor
Is this the exact code that caused the error? I don't see any reason why Line 35 (pnt = xy) should be trying to access any workspace at all. Also, Line 1 should have a syntax error (the character before the comment) and Line 39 should be 'editor' not 'edit'.
edit: I see that your current Line 18 should be split across several lines, which is messing up your Line numbering. What is supposed to be Line 35?
So, your workspace definition is invalid. There could be several reasons for that, but for starters, spaces in pathnames are never a good idea. In fact anything outside [a..z][0..9]_ should be avoided.
once that is solved... it will be time to move on to how the coordinates are collected and which are the actual coordinates (I would check field name spelling first). Another reason to work on a local drive, then upload results.
Besides the comments above, I don't see where you mention the version you are using. Did it break after upgrading ArcGIS Server? Using a service like 5151 is not available in the current versions and you you may benefit from switching this to a Direct Connect.
That is an older blog, but might get you headed in the right direction with Direct Connects.
This does seem like a pathing issue:
folderNamer fileName filepath r
The full file path in the filePath variable has an "Auto" in it, which seems out of place given your folderName and fileName variables.