9

I'm using ArcGIS 10.1 and setting up some scheduled tasks to run on our server. I am calling a python script in a .bat file.

When it runs, the connection to our SDE database is "invalid" or do not exist/supported.

However, if I open ArcCatalog and connect to our SDE it runs without a hitch.

In the script I have a few feature classes referenced as this:

Database Connections\\Connection to gisserver.sde\\master.DBO.Blah\\master.DBO.Towns

And the SDE as :

masterSDE = "Database Connections\\Connection to gisserver.sde"

I want this script to be automated overnight, so opening up ArcCatalog is not an option.

Is there a way to establish a connection to databases (SDE's) like you would in ArcCatalog programmatically?

0

1 Answer 1

13

You need to be sure the SDE connection file you want to use is accessible by the user running the script, on the machine running the script.

"Database Connections" is a shortcut to a folder under the current user profile, e.g.: %APPDATA%\ESRI\Desktop10.1\ArcCatalog. You do NOT have to use this shortcut! You can just as easily specify the full path to the file. You can put the file anywhere, but I would recommend a secure network location that only the appropriate users can access.

If you want to create the SDE connection file programmatically you can use the Create Database Connection or Create ArcSDE Connection tools.

The main difference between these two tools is that the former is intended for direct (2-tier) connections to the database, while the latter is intended for application server (3-tier) connections through an ArcSDE service, although in practice you can use the latter for direct connections as well.

0

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.