We have a new Fabric built, at my organization, and I am reaching out to see if anyone has had success exporting the feature classes inside of the Fabric dataset to another geodatabase, using Python. I have created a simple Python script using the FeatureClassToFeatureClass_conversion ArcPy function. This script works as it is designed for features classes in file geodatabases. It also works on feature classes in Enterprise geodatabases. However, when I tried to run my script, to export feature classes from the Fabric dataset, in an Enterprise geodatabase, I get an error:
LandRecordsMapping.ENTERPRISE.PARCEL_LOT_POLYGONS does not exist or is not supported
This feature class does exist inside the Fabric Dataset. Here is a picture of the feature class that exists in the Fabric dataset:
This script error makes me think that the feature class from the Fabric dataset is not supported for this script. I did some research and found something that said feature classes in a feature dataset, with attribute rules, are not readable with arcpy. I’m not sure if this is true, but the “not supported” part of the script error leads me to believe that ArcPy is not detecting my feature class because it isn’t readable from ArcPy.
How can I run the FeatureClassToFeatureClass function, from my Parcel Fabric dataset, using ArcPy? If it can’t be done using ArcPy, how else can I export feature classes from a fabric dataset (with attribute rules) to another geodatabase, as a non-fabric feature class.
My python script is attached and looks like this:
Note: I have successfully run the Feature Class to Feature Class tool in a model in ModelBuilder, in ArcPro, to export a feature class in the Fabric dataset to another geodatabase. This works as I expect it to, but I was hoping I could do this task in a simple python script instead.
Thank you for any advice.
I have not worked with sde at all, however, in a regular FGDB I use arcpy with feature classes that have attribute rules all the time.
I would try adding an 'r' to the beginning of your file paths, like you did for the workspace, to be sure that the file path is read correctly.
Spaces and escape sequences (\n, \b, \f, etc) can confuse file paths.
Thank you for the suggestions Paul. I added the 'r' to the beginning of my file paths, but the python script still comes up with the same error. I appreciate your response.
It looks to me like you're setting the environment workspace to a file geodatabase while working between two enterprise geodatabases. That shouldn't be a problem but, try commenting out that line or set the env.workspace to your inFeatures SDE connection file.
arcpy.env.workspace = <inFeatures_connection_file.sde>
Also, do you get the same error running the Feature Class to Feature Class geoprocessing tool from Pro?
Thank you for the advice Ken.
I tried my script after removing the workspace line of code and it still came up with the same error. I tested my script by replacing the input with a feature class outside of the fabric dataset and the script ran without error. However, once I make the input for my Feature Class to Feature Class function, a feature class inside of the fabric dataset, I get the same error about my feature class not existing or not being supported. I have verified that it exists.
I did run the Feature Class to Feature Class Tool in ArcPro using the feature class (PARCEL_LOT_POLYGONS) inside of the Fabric dataset and it ran without fail or error. I think its great that it works in ArcGIS Pro, but why doesn't it work in my python script?
Update: False alarm. My error came from a different issue. However, staying with the path theme, can you confirm that the same path used the GP tool or model builder is the same path in the script?
I was able to reproduce the error by putting my .sde connection file in a path with a very long character length.
I know there are technically limitations on path character lengths in Windows, Python and ArcPy but I'm not sure which one(s) is occurring here since it works from the GP tool and Model Builder. My path above is 252 characters long so I don't think my issue is Windows.
Please try to shorten the inFeatures path length and see if that helps. I'll see if I can find more info.
Thanks for the idea about the file path name being too long. However, I edited my python script, with a reduced file path length, by renaming my ArcGIS Pro project database connections, and created a new ArcGIS Pro project. I am still getting an error. I even copied and pasted the file path of the input feature for the Feature Class to Feature Class tool directly from the ArcPro Model (ModelBuilder) into my python script. The ArcPro Model works perfectly. However, my python script still comes up with an error: