how can append work with sde data?

738
4
04-20-2011 09:45 AM
FrankVignati
Occasional Contributor II
in a python script

       ## THIS WORKS IN AN EDITING SESSION ON A FILE GEODATABASE FEATURE CLASS
       arcpy.Append_management(SourceData,TLyr,"NO_TEST")
       
       ## THIS DOES NOT WORK FOR AN SDE DATABASE FEATURECLASS
       arcpy.Append_management(SourceData,BLLyr,"NO_TEST")


the error returned is:
Runtime error <class 'arcgisscripting.ExecuteError'>: ERROR 000210: Cannot create output \propertyappraisal.DBO.PA_Basemap\propertyappraisal.DBO.basemap_arc Failed to execute (Append).

is there a way around this?
Tags (2)
0 Kudos
4 Replies
FrankVignati
Occasional Contributor II
maybe there is another way to do what i want, copy lines from a geoprocessing output into a sde feature class in arcmap
currently the output is being written to a file geodatabase


## Import standard modules
import sys, os

## Set the necessary product code
import arcinfo

## Import arcpy module and environment module
import arcpy
import arcpy.mapping
from arcpy import env

## Overwrite pre-existing files
arcpy.env.overwriteOutput = True

## Sets the MXD file
IMXD = arcpy.mapping.MapDocument("CURRENT")

DF = arcpy.mapping.ListDataFrames(IMXD, "Layers")[0]
try:
   for ILayer in arcpy.mapping.ListLayers(IMXD):
       if ILayer.name == "AGHXL":
           arcpy.mapping.RemoveLayer(DF, ILayer)
except:
   arcpy.GetMessages()
       
## Refresh map
arcpy.RefreshTOC()
arcpy.RefreshActiveView

## Set Relevant Layers
ALyr = arcpy.mapping.ListLayers(IMXD,"address_point")[0]
BLLyr = arcpy.mapping.ListLayers(IMXD,"Basemap_Line")[0]

try:
   ## Test for slected address points
   NumS = str(arcpy.GetCount_management(ALyr))
   Num = int(NumS)
   if Num > 1000:
       # print "Please select an address point"
       arcpy.AddMessage("PLEASE SELECT AN ADDRESS POINT")
   elif Num > 1 and Num < 1000:
       # print  "Please select only one address point"
       arcpy.AddMessage("PLEASE SELECT ONLY ONE ADDRESS POINT")
   else:
       ## Get the XY of the selected address point
       ACur = arcpy.SearchCursor(ALyr)
       for ARow in ACur:
           ACenter = ARow.shape.centroid
           AX = ACenter.X
           AY = ACenter.Y
       ## Set the corners for the AGHX polygon  
       PNT1X = AX - 12.5
       PNT1Y = AY + 12.5

       PNT2X = AX + 12.5
       PNT2Y = AY + 12.5
  
       PNT3X = AX + 12.5
       PNT3Y = AY - 12.5

       PNT4X = AX - 12.5
       PNT4Y = AY - 12.5

       PNT1 = r"%s,%s"%(PNT1X, PNT1Y)
       PNT2 = r"%s,%s"%(PNT2X, PNT2Y)
       PNT3 = r"%s,%s"%(PNT3X, PNT3Y)
       PNT4 = r"%s,%s"%(PNT4X, PNT4Y)

       BArray = arcpy.Array()
       COORDS = [PNT1, PNT2, PNT3, PNT4]
       for COORDPAIR in COORDS:
           X, Y = COORDPAIR.split(",")
           X = float(X)
           Y = float(Y)
           PNT = arcpy.Point(X,Y)
           BArray.add(PNT)
       BArray.add(BArray.getObject(0))
       NPolygon = arcpy.Polygon(BArray)
       arcpy.FeatureToLine_management(NPolygon, "C:\\WorkSpace\\GeoProcessingTemp.gdb\\ScratchData\\AGHXL","","NO_ATTRIBUTES")

       del ACur, ARow

       SourceData = "C:\\WorkSpace\\GeoProcessingTemp.gdb\\ScratchData\\AGHXL"
       AGHXLayer = arcpy.MakeFeatureLayer_management(SourceData,"AGHXL")

       arcpy.SetParameterAsText(0,NPolygon)
       arcpy.SetParameterAsText(1, AGHXLayer)
       
       ## Refresh map
       arcpy.RefreshTOC()
       arcpy.RefreshActiveView
       

except:
   arcpy.GetMessages() 
0 Kudos
MathewCoyle
Frequent Contributor
If you are getting a 210 error there is a problem with your write access to your target. I would test for a schema lock on your target feature class. Versioning might be an issue also depending on the setup of your database and your privileges.
0 Kudos
FrankVignati
Occasional Contributor II
our sde database is versioned, the layer i am trying to write to is from a database connection with rights to edit the data
can python write to sde versioned data if done within an editing session?
0 Kudos
FrankVignati
Occasional Contributor II
well, it seems the workspace had to be set with the sde connection in order for it to write to the layer

this is how the workspace is set, does anyone know a less ugly way?

       SDEInfo = BLLyr.serviceProperties 
       UserInfo = str(SDEInfo.get('UserName'))
       UserInfoSplt = UserInfo.split("\\")
       User = UserQ.rstrip('"')
       User = User.lower()
       IWork = r"C:\\Documents and Settings\\%s\\Application Data\\ESRI\\Desktop10.0\\ArcCatalog\\%s@propertyappraisal.vgisdb1.sde"%(User, User)
       arcpy.env.workspace = IWork
       
0 Kudos