Select to view content in your preferred language

Trying to run a model / script as a scheduled task

4018
12
06-12-2012 08:34 AM
SharonZastre
Emerging Contributor
Hello,

I have created a model that will Analyze, Sync, and Compress data within a SQL Enterprise geodatabase (ArcGIS 10 SP4). The model runs fine in ArcCatalog. I exported the model to a python script and it runs fine in ArcCatalog as well. But when I run the python script as a scheduled task it seems to run but the data doesn't sync between the databases. I also tried the option of setting up a scheduled task to run a python script / bat file that calls the model itself. This doesn't seem to process properly. Not sure what I am missing but I'm not familiar with python so I don't really know where to begin. Any ideas are appreciated.

Thanks,
Sharon
Tags (2)
0 Kudos
12 Replies
BruceBacia
Frequent Contributor
We had this problem the other day at work.  Instead of "Database Connections\\SQL GISPW@Owner.sde\\GISPW.OWNER.PW_SewerNetwork", you must list the full path to the sde connection.
0 Kudos
KenCarrier
Deactivated User
This handy little piece of code should help get you started

Run the code below in IDLE or whatever IDE you are using for python:

for k in os.environ: print "%s: %s" %(k, os.environ)

This will give you a list of all the environment variables you can reference to make building your paths easier.

Once you have a look at the above try to follow this, this will list all the sde connections in your DatabaseConnections folder.

import os, arcpy
from arcpy import env
path = os.path.join(os.environ['APPDATA'],'ESRI\\Desktop10.1\\ArcCatalog')
env.workspace = path
workspaces = arcpy.ListWorkspaces("*","SDE")
for workspace in workspaces:
    print workspace


Hope this helps!
0 Kudos
BruceBacia
Frequent Contributor
Many thanks for the tips Ken!  Very useful
0 Kudos