3

My project aims at updating automatically point feature classes in a ESRI local geodatabase using MySQL tables with X,Y coordinates. The updates should be launched with the Windows task-scheduler. I am following closely the process described on blogs.esri.com, using ArcGIS 10.1 on Windows Server 2008 R2 Standard. I work in folder where I have full R/W permissions.

I have created the OLE DB connexion in ArcCatalog (following this GIS-SE post), and a ModelBuilder to run the conversion process. It works fine when launched in ArcCatalog.

I have created this ArcPy script to launch the ModelBuilder :

    # -*- coding: utf-8 -*-
    import arcpy

    # Import the toolbox containing the model.  
    arcpy.ImportToolbox(r"c:\myTBX.tbx", "myTBX")

    # Run the model "myTool".  The model has two parameters:
    #    1- the geodatabase to update
    #    2- the input connection file to MySQL:

    out_geodatabase = r"c:\mygeodatabase.gdb"
    in_connection = r"c:\myConnection.odc"

    arcpy.myTool_myTBX(out_geodatabase, in_connection)

    print "process complete"

What I get is an errror message that says that the connection to MySQL does not exist or is not supported: the behaviour is different is I call the Model from within ArGIS (runs without error) or from ArcPy outside a user session (the connection to MySql is not recognized).

Does anyone know why this is happening, and how I could resolve it?

6
  • It seems you could implement the whole workflow in Python instead of using ModelBuilder - as you see it can get harder to troubleshoot. Commented Jun 30, 2016 at 14:42
  • @AlexTereshenkov Can you advise on how to connect to MySQL in Python?
    – Hélène
    Commented Jun 30, 2016 at 14:55
  • You can try using MySQL Connector/Python or pyodbc to connect to MySQL.
    – Ken
    Commented Jun 30, 2016 at 15:22
  • 1
    I notice that your toolbox,gdb and odc files are on the ROOT of your c:\ drive. You don't say which version of Windows you are using. I've had problems with permissions on windows 8.1 when accessing files on the root of c:\, so I would suggest moving everything into a folder you have read/write access such as c:\temp\projectX. Worth a try?
    – Hornbydd
    Commented Jun 30, 2016 at 16:18
  • @Hélène, you would just use the same geoprocessing tools you use in ModelBuilder in Python instead using arcpy package. Commented Jul 1, 2016 at 5:49

1 Answer 1

2

I run the process on a server where both the 64-bits and 32-bits versions of Python are installed, as the server holds both ArcGIS Desktop and ArcGIS Server.

By default, the 64-bit version is launched, and my script fails. I forced the 32-bit version use by launching the script from the command line, and the update went through successfully.

    C:\>C:\Python27\ArcGIS10.1\python.exe C:\myScript.py 

This solution is derived from http://support.esri.com/technical-article/000011711. However, setting the 32-bit python as the default program did not suffice.

Your Answer

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

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