Simple Python Script Runs on Desktop but Not Server

4025
8
Jump to solution
07-29-2014 12:59 PM
DanielHorn
New Contributor II

I wrote a python script that simply lists out all of the feature classes in our SDE database, which I'm running directly through the Python Shell. The script will eventually export feature classes from our SDE database to a file geodatabase via Windows Task Scheduler, but I was having trouble getting that to work, so I simplified it to do some testing. The script is below:

import arcpy

from arcpy import env

env.workspace = "//mplgis-fs.moc.com/gis_data/connections/ConnectiontoMPLGIS-TEST.sde"

print arcpy.ListFeatureClasses()

On my desktop PC (Win 7 64-bit, ArcGIS for Desktop 10.2.2), the script executes correctly and returns the list of features:

working.jpg

But when I run it on the server (Windows Server 2008R2, ArcGIS for Server 10.2.2), it does not return any feature classes, and I'm stumped as to why that is:

notworking.jpg

Any thoughts on what might be causing it? In the screenshots I show that the server is using the ArcServer license, while the desktop is using the ArcInfo, but I'm not sure if that should make a difference.

0 Kudos
1 Solution

Accepted Solutions
DanielHorn
New Contributor II

I finally figured out the issue (after far too long, I might add!). SQL Server Native Client was installed, but the connection file was setup using an alias to the database server, not the server name itself. The database aliases are stored in the registry on each machine and they had not been pushed to any of the new GIS servers we had provisioned. I got the registry file that I needed to create the proper entries and it works perfectly now.

Thanks for the help!

View solution in original post

0 Kudos
8 Replies
DanielHorn
New Contributor II

I did some further investigation. I was able to use the ListFeatureClasses() method on a file geodatabase succesfully from the server, so it appears like it may be an issue when accessing the SDE through the connection file. The connection file is setup as a database connection with databse authentication, and I don't have any issues accessing the feature classes through ArcCatalog on my desktop.

0 Kudos
RussellBrennan
Esri Contributor

Daniel,

Have you installed the SQL Server native client on your server machine? This might be the reason you are not able to connect to the database. Try installing the native client and then rerunning the script.

0 Kudos
DanielHorn
New Contributor II

I finally figured out the issue (after far too long, I might add!). SQL Server Native Client was installed, but the connection file was setup using an alias to the database server, not the server name itself. The database aliases are stored in the registry on each machine and they had not been pushed to any of the new GIS servers we had provisioned. I got the registry file that I needed to create the proper entries and it works perfectly now.

Thanks for the help!

0 Kudos
MichaelTorbett1
Occasional Contributor

Hey Daniel,

I also am having this issue. I have a simple script that runs fine on desktop but not Server. I'm getting the error "00732 connection to "Database Connections\\Connection to               GFCARCSERVER.sde\\gfcgis.DBO.FIREDATAFINAL_OFFICIAL"database does not exist or is not supported." 

Where do I find the database Aliases in the Registry.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Your issue may not be related to database aliases.  Seeing the error message, it appears you are using a relative path (from Database Connections folder) instead of a fully qualified path.  Does the server have a copy of the "Connection to GFCARCSERVER.sde" file on it?

MichaelTorbett1
Occasional Contributor

Hey Joshua,

No, the sde connection file is just on my local machine. Are you saying that I need to add the file onto the server and provide a full path to it in my script?

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Yes.  The path to the SDE connection file needs to be accessible by the process executing the script.  If the SDE connection file exists only on your machine, and a process on the server has no way to access that SDE connection file, then it will fail.  In the code 2 years ago by the OP, the SDE connection file appears to be stored on a file share that was likely accessible by both the desktop and server.  In your case, the SDE connection file is stored on the desktop and is inaccessible to the server.

MichaelTorbett1
Occasional Contributor

It worked!!!! Thank you for your help Joshua.

0 Kudos