Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created and modified python scripts based off of ERSI's example (, however, what would be great is to be able to batch process these files using python.

I attempted trying model builder by adding two database connections to the compress tool. (That didn't work.) Obviously, right-clicking on the tool in ArcToolbox brings up the option for batch, but I have no idea how to do this for python.

I can not seem to find anywhere the ability to do this. It's a pain to have ten scripts running the same thing but with different databases. Anyone know how to do this with python? Thank you in advance.

share|improve this question
up vote 1 down vote accepted

create a variable for each connection and then add these variable to a list

ws1 = r'D:\Temp\conn1.sde'
ws2 = r'D:\Temp\conn2.sde'
ws3 = r'D:\Temp\conn3.sde'
WSS = [ws1,ws2,ws3]
for ws in WSS:
    arcpy.RebuildIndexes_management(ws, "SYSTEM", dataList, "ALL")
    arcpy.AnalyzeDatasets_management(ws, "SYSTEM", dataList, "ANALYZE_BASE",  "ANALYZE_DELTA", "ANALYZE_ARCHIVE")
share|improve this answer

Could you create a python list with your 10 different database connections? Then loop through the list:

for db in databases:
    #connect to db
    #compress db
    #disconnect from db

You might need a dictionary if your connection properties differ for each database.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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