I am attempting to use the Production Mapping Data Load tool to copy data from one database into another with a differing schema. Something I've done manually several times, but would prefer to script it out to save some time. Unfortunately I've run into some issues, and was hoping someone may point me in the right direction.
Code Sample:
import arcpy
try:
if arcpy.CheckExtension("Foundation") == "Available":
arcpy.CheckOutExtension("Foundation")
else:
raise LicenseError
arcpy.LoadData_production(crossReference, sourceDatabase,
targetDatabase, logRowErrs)
except LicenseError:
"Production Mapping License unavailable"
Returns:
AttributeError: 'module' object has no attribute 'LoadData_production'
It is worth mentioning this is the result when I execute the code from a *.py - when I copy and paste the code into an ArcMap Python window it runs fine.
I would appreciate any guidance!
V/R,
Forbes
Hi Ryan,
Thank you for providing the code sample.
What value are you specifying for the logRowErrs variable?
For Load Data, the order of the parameters is the following:
1. in_cross_reference
2. in_sources
3. in_target
4. in_dataset_map_defs
5. row_level_errors
Depending on what you have specified for the logRowErrs variable, you might be specifying a row_level_errors value (i.e. ROW_LEVEL_ERROR_LOGGING or NO_ROW_LEVEL_ERROR_LOGGING) for the in_dataset_map_defs parameter.
When I open ArcMap and launch the Python window and specify logRowErrs = 'ROW_LEVEL_ERROR_LOGGING' and execute the following:
arcpy.LoadData_production(crossReference, sourceDatabase, targetDatabase, logRowErrs)
I encounter the following:
ExecuteError: Failed to execute. Parameters are not valid. ERROR 000800: The value is not a member of ...
What happens if you execute the following:
arcpy.LoadData_production(crossReference, sourceDatabase, targetDatabase, '#', logRowErrs)
Regards,
Dan
Hi Dan,
Thank you for looking into this and helping me out!
You wrote:
"When I open ArcMap and launch the Python window ..."
The issue I am facing is that the LoadData_production function is not being recognized when called outside of ArcMap. When I run the code from an ArcMap Python window it runs fine -- I am trying to run my script from the command line/IDE, that way I can have the script execute while I am not physically present.
Here is my code in its entirety without any truncation for expediency --
import arcpy
class LicenseError(Exception):
pass
try:
if arcpy.CheckExtension("Foundation") == "Available":
arcpy.CheckOutExtension("Foundation")
else:
raise LicenseError
crossReference = r"C:\Temp\dataloadTest\dataload_crossref.mdb"
sourceDatabase = r"C:\Temp\dataloadTest\dataLoad_source.gdb"
targetDatabase = r"C:\Temp\dataloadTest\dataLoad_target.gdb"
logRowErrs = "ROW_LEVEL_ERROR_LOGGING"
arcpy.LoadData_production(crossReference, sourceDatabase, targetDatabase,
"#", logRowErrs)
except LicenseError:
print "Production Mapping License unavailable."
except arcpy.ExecuteError:
print(arcpy.GetMessages(2))
To reiterate - when I execute this in ArcMap it runs perfectly fine. However, my goal is to have this run from the command line via a scheduled task during off hours. When executed from IDLE for example (or your superior IDE of choice) it fails to recognize arcpy.LoadData_production entirely.
I suspect when I import arcpy from outside of ArcMap something is failing to instantiate, or something different happens when you import arcpy from inside of ArcMap.
Ryan,
Thank you for responding.
The code that you have provided in its entirety executes without issue on my 10.7.1 machine.
Please answer the following:
1. What is the OS of your machine?
2. What is the build number for ArcMap? Launch ArcMap and go to Help->About ArcMap..
4. What is the build number for Production Mapping? Launch ArcMap and go to Customize->Extensions... and the Extensions dialog is launched. On the Extensions dialog, highlight Production Mapping with your cursor and the 'Build Number' will appear under 'Description'.
Regards,
Dan
Dan,
ArcMap is 10.6.1.9270 and I am showing build number 997 for Production Mapping.
V/R,
Forbes
Ryan,
Thank you for responding.
My physical machine is running the following:
- OS Windows 10
- ArcGIS Desktop 10.6.1 Build 9270
- Mapping and Charting Solutions Desktop 10.6.1 Patch 1 Build 997
The code that you have provided in its entirety executes without issue.
Have you tried repairing Mapping and Charting Solutions Desktop 10.6.1?
Please answer the following:
1. What is the OS of the machine (I did not get an answer to this question in my previous post)?
2. What other Esri software is installed on your machine (e.g. ArcGIS Sever, Desktop Background GP)?
Regards,
Dan