2

When trying to copy a feature class from an SDE connection file to a scratch GDB, the FeatureClassToFeatureClass_conversion works in the ArcMap Python window, but I can't get it to work in a Python script. In ArcMap, the code looks like this:

pathScratchGDB = arcpy.env.scratchGDB + os.path.sep
arcpy.FeatureClassToFeatureClass_conversion("C:/SmartFarm_Tools/smartfarm_connection.sde/smartfarm.master.zone_catalog", pathScratchGDB, "fcZones", 'fldid_id = ' + str(504) + " and type = 'BW2014'")

which results in:

<Result 'C:\\Users\\username\\Documents\\ArcGIS\\scratch.gdb\\fcZones'>

In my Python script I have the exact same code:

pathScratchGDB = arcpy.env.scratchGDB + os.path.sep
arcpy.FeatureClassToFeatureClass_conversion("C:/SmartFarm_Tools/smartfarm_connection.sde/smartfarm.master.zone_catalog", pathScratchGDB, "fcZones", 'fldid_id = ' + str(504) + " and type = 'BW2014'")

which results in:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python27\ArcGISx6410.3\lib\lib-tk\Tkinter.py", line 1486, in __call__
    return self.func(*args)
  File "C:\SmartFarm_Tools\python_scripts\SmartFarm_Engine1.py", line 1228, in onLoad
    arcpy.FeatureClassToFeatureClass_conversion("C:/SmartFarm_Tools/smartfarm_connection.sde/smartfarm.master.zone_catalog", pathScratchGDB, "fcZones", 'fldid_id = ' + str(504) + " and type = 'BW2014'")
  File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\conversion.py", line 1789, in FeatureClassToFeatureClass
    raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset C:/SmartFarm_Tools/smartfarm_connection.sde/smartfarm.master.zone_catalog does not exist or is not supported
Failed to execute (FeatureClassToFeatureClass).

In the same Python script I am able to successfully run this line of code:

arcpy.FeatureClassToFeatureClass_conversion("C:/SmartFarm_Tools/smartfarm_connection.sde/smartfarm.master.boundary_2015", pathScratchGDB, "fcBound", 'master_id = ' + str(inMasterID))

Has anyone seen this before?

EDIT

The data resides on a PostgreSQL/PostGIS database.

5
  • Can you edit your question and provide info on the RDBMS your enterprise GDB in and can you try running your code in 32bit python to see if it works.
    – user2856
    Mar 4, 2016 at 21:12
  • @Luke Running it in 32 bit would require me to install no small number of 32 bit Python modules. If the same ArcPy function runs successfully on the same PostGIS database in the same Python script, what would a 32 vs 64 bit run have to do with the issue? (I don't mean for this question to sound rude, I'm genuinely curious)
    – GISUser9
    Mar 4, 2016 at 21:30
  • 3
    You don't have to run your whole script, just the featureclasstofeatureclass bit. The reason is that you may not have a 64bit db driver installed correctly/at all. If it runs from ArcMap python window, it's using 32bit
    – user2856
    Mar 4, 2016 at 21:36
  • @Luke Wow, you're a genius! Sorry I doubted. So FeatureClassToFeatureClass_conversion worked in 32-bit. I'm assuming that means I'm missing a 64-bit db driver? Any suggestions on where to look?
    – GISUser9
    Mar 4, 2016 at 21:45
  • We have the same problem with our Oracle GDB as IT only installs the 32bit Oracle client. Sorry don't know about Postgres
    – user2856
    Mar 4, 2016 at 21:53

2 Answers 2

2

I've encountered this and similar issues when trying to run geoprocessing tools against our Oracle enterprise GDB. Connecting to the Oracle GDB works fine in 32bit ArcGIS Desktop, however running geoprocessing tools in 64bit python, either standalone or via background geoprocessing, fails as as our IT provider only installs a 32 bit Oracle client.

I suggest you ensure you have a 64bit PostgreSQL driver installed and configured correctly.

1

With Luke's help I was able to determine that it was a 32 vs. 64 bit issue. As a workaround, I wrote a quick script that I call with a 32 bit python.exe using subprocess.Popen:

Popen([r"C:\Python27\ArcGIS10.3\python.exe", r"C:\Temp_Tools\python_scripts\post2fc.py", "lsCatalogID=" + str(lsCatalogID)], stdout=PIPE)

The code for the post2fc.py looks like this:

import arcpy

inList = arcpy.GetParameterAsText(0)
exec(inList)

arcpy.env.overwriteOutput = True

pathScratchGDB = arcpy.env.scratchGDB + os.path.sep

arcpy.FeatureClassToFeatureClass_conversion("C:/Temp_Tools/temp_connection.sde/temp.master.zone_catalog", pathScratchGDB, "fcZones", 'id IN ' + str(tuple(lsCatalogID)))

Your Answer

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

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