Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I created and modified python scripts based off of ERSI's example (http://resources.arcgis.com/en/help/main/10.2/index.html#//003n000000v7000000), 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

2 Answers 2

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. http://yuji.wordpress.com/2008/05/14/python-basics-of-python-dictionary-and-looping-through-them/

share|improve this answer

Your Answer

 
discard

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.