Append data not appending attributes

4244
18
03-23-2018 09:21 AM
MartinSirkovsky1
New Contributor III

I create a script to append data from feature class in FGDB to SDE (MS Sql DBMS). I use "no_test" on append.

Script works fine, data get appended, but no attributes are transfered, just geometry. When I run the command manually, or if I set target to be another FGDB, it works.

Does anybody experienced this before?

Tags (2)
18 Replies
XanderBakker
Esri Esteemed Contributor

After you manually run the tool the way it works copy the Python snippet from the Results window and compare the code with what you are using in your script. I'm sure it will contain information on the field mapping. 

JustinPierre
New Contributor II

It's probably related to the field mapping from the file geodatabase to the SDE database.

Field mapping and Python scripting | ArcGIS Blog 

As Xander suggests, if you copy the Python snippet from ArcMap it will include the field mapping you need

arcpy.Append_management(

inputs="some featureclass'",

target="some sde",

schema_type="NO_TEST",

field_mapping='a very long string of mapped attributes',

subtype=""

)

MartinSirkovsky1
New Contributor III

I don't think there is a problem in my field mapping. This are the reasons why:

  • I have copied it from python snippet
  • When I run it against FGDB it works
  • When I run my append code in Python's console in ArcMAP it works (target is SDE)

I am wondering if it might be some issue with MS SQL. It is a first time I have experienced such a strange behaviour, and I did append many many times via scripting, however never against MS SQL.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

How are you executing your code when not in the interactive Python window in ArcMap?

0 Kudos
MartinSirkovsky1
New Contributor III

I am using Sublime text 3 to execute my code. But I think I also tried directly from command prompt. I did this operation 1000 times before. Please notice, that all the features are appended to target FC, just all attributes have value NULL.

0 Kudos
MatthewDobson
Occasional Contributor

Martin.

What version of ArcGIS are you using, and are there map services consuming the featureclasses that you are attempting to append to??

0 Kudos
MartinSirkovsky1
New Contributor III

Hey Matthew.

I am using ArcGIS 10.5.1, and there are currently no Feature Classes consuming the services.

0 Kudos
MartinSirkovsky1
New Contributor III

So I did some testing. Here is something interesting. 

I have set up the input feature class in a way that I can append it with "TEST" value in "schema_type" parameter.

  • Running script from ArcMAP both with NO_TEST and TEST as schema type gives correct result
  • Running the script as a python script with NO_TEST as schema type results in FC being appended but no attributes are transfered
  • Running the script as a python script with NO_TEST as schema type results in FC being appended together with attributes

So it seems that there some kind of bug, when running append command from python script with "NO_TEST" as schema type against feature class in MS SQL SDE.

Anyone have any idea how to solve this issue?

0 Kudos
MartinSirkovsky1
New Contributor III

CORRECTION TO ABOVE POST:

  • Running script from ArcMAP both with NO_TEST and TEST as schema type gives correct result
  • Running the script as a python script with NO_TEST as schema type results in FC being appended but no attributes are transfered
  • Running the script as a python script with TEST as schema type results in FC being appended together with attributes
0 Kudos