Select to view content in your preferred language

Standalone Python script to Read MDB on a Server?

776
6
04-11-2013 03:46 PM
KarenFolger
Frequent Contributor
I've got a python script that reads a table in Access and does a Make XY Event Theme, copies data and creates an SDE layer. I'm trying to get it to run in the SQL Server Jobs agent on a schedule.  The script works on my desktop, both in ArcCatalog and stand-alone IDLE.  However, I'm trying to run it on a server where there is no Access install (Server 2008 R2). 

I've tried making an ODBC connection file and using the connection file in python which only partly works.   The data copies OK to SDE on the server if I run the script in ArcCatalog. 

If I run on the server using python.exe in SQL server job agent, the job bombs because it can't find the Access table.  Same as when I try to run with IDLE.  Weird. 

Is there a way to code the connection to the mdb in python so that it knows about the mdb?  Otherwise we could install Access on the server, not my favorite idea.

All using ArcGIS 10.1
Tags (2)
0 Kudos
6 Replies
by Anonymous User
Not applicable
I see that you are using 10.1...Have you by chance installed the 64 bit background processing?  If so, this will not be able to read any personal gdb's.  You will have to force python to run the 32 bit IDLE to read the mdb.
0 Kudos
KarenFolger
Frequent Contributor
No, I have not installed any special 64 bit background processing.  I'm just using the python.exe to run the script.  If anyone knows the code for a connection string inside python for connecting to mdb's let me know.
0 Kudos
KevinHibma
Esri Regular Contributor
As Caleb1987 said, Background, and Server as well (64-bit) will not read personal geodatabases.
That said, making an ODBC connection to the .mdb may work. I haven't tested, but the biggest difference in the two workflows you're trying is the 32 vs 64 bit.
I suspect you'll need to get the 64bit drivers to make this work. This KB article provides a good starting point and download links:
http://support.esri.com/en/knowledgebase/techarticles/detail/32976  (make sure you get 64bit links for the Server machine)
0 Kudos
KarenFolger
Frequent Contributor
So I'm not sure what you're saying exactly.  The server is a 64-bit machine.  I can see the access database through ArcCatalog using the 32-bit drivers.  Access is only 32-bit, ArcGIS is only 32-bit.  What I cannot see is the access mdb in Python outside of ArcGIS.  I have made a odc connection file is ArcCatalog - which works fine in ArcCatalog, however Python isn't recognizing it.
0 Kudos
KevinHibma
Esri Regular Contributor
Oh - you have BOTH Desktop and Server installed the same machine?
If thats the case you have both 32 and 64 bit Python.
If the last software you installed was Server, by default Python will be using 64bit. (that is if you simply double click a python script, it'll be executed using 64bit Python).
You need to explicitly use the 32 bit version of Python.
See this blog article - http://blogs.esri.com/esri/arcgis/2012/11/12/python-scripting-with-64-bit-processing/ - while its written for background, its true for Server as well. The short message is: if you have 32 and 64 bit versions of Python installed on the same machine, you should be referencing a specific version when executing your scripts.
0 Kudos
KarenFolger
Frequent Contributor
I was using the 32-bit call already - here's the line

C:\Python27\ArcGIS10.1\python.exe "D:\Scheduled Scripts\StudySites2SDEodbc.py" which throws

File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py"<c/> line 6322<c/> in MakeXYEventLayer      raise e  arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.  ERROR 000732: XY Table: Dataset J:\data\StudySitesDatabase_Be.mdb\ExportAllStudySites does not exist or is not supported  Failed to execute (MakeXYEventLayer).  Process Exit Code 1.  The step failed.,00:00:16,0,0,,,,0

Again, it's visible in ArcCatalog on the server, just not in Python.  If anyone knows the code for mdb reads in Python that would be awesome!
0 Kudos