Looping thru Databases in order to List Versions

Discussion created by winoker on Aug 8, 2012
Latest reply on Sep 4, 2012 by mzcoyle
Hi.  I am new to the Python scene, and just started learning about it.  I am trying to figure out how to accomplish what I think is a simple task.  Basically, I want to make a list of versions that are in our sde databases.

This is what I have written so far:

import arcpy
from arcpy import env
env.workspace = "Database Connections"
dbList = ["CIP", "Ems", "MMS", "Prod", "Storm", "Utils", "WCS"]

##sdeDB = "SQL" + str(dbList) + ".sde"
##The result of this line of code is: SQL[CIP, Ems, MMS, Prod, Storm, Utils, WCS].sde & it is not what I want

for list in dbList:
print list

I know that it is primitive, and is probably wrong in so many ways.  Having said that, this is what I am trying to do:

--Look in ???Database Connections??? at the individual databases
--Make a list
--Add ???SQL??? in front of each item in the list
--Add ???.sde??? to the end of each item on the list
     These are the sde database names

For the second part of the script, I???d like to:

--Find the versions in those databases
--See a list of the versions in each of the databases

Here is what I have drafted so far to see the list, but it is only for SQLUtils.sde:

versionList = arcpy.ListVersions(r"Database Connections\SQLUtils.sde")
for version in versionList:
   print version

This script works just fine, but only for SQLUtils.sde, but I want to get it to loop thru sde databases in Database Connections after it appends the ???SQL??? prefix and the ???.sde??? extension to the database name.

I know that I could simply type the "SQL" and ".sde" to the items in the list, but where is the challenge in that?

Any suggestions?  I'd really appreciate your help.