import arcpy def main(): try: sdeConnList = ["Database Connections\\ORCL - SDE@SERVER.sde", "Database Connections\\ORCL1 - SDE@SERVER1.sde", "Database Connections\\ORCL2 - SDE@SERVER2.sde", "Database Connections\\ORCL3 - SDE@SERVER3.sde"] for sdeConn in sdeConnList: fcCount = 0 fdCount = 0 wk = arcpy.env.workspace = sdeConn if arcpy.Exists(wk): print("\n\n SDE Connection File EXISTS : " + sdeConn) fdList = arcpy.ListDatasets("*") for fd in fdList: fdCount += 1 fcList = arcpy.ListFeatureClasses("*") for fc in fcList: fcCount += 1 print(" # of Feature Datasets in this workspace : {0}".format(str(fdCount))) print(" # of Standalone Feature Classes in this workspace : {0}".format(str(fcCount))) else: print("\n\n SDE Connection File DOES NOT EXIST : " + sdeConn) print("\n\n COMPLETED!! \n\n") except arcpy.ExecuteError: print (arcpy.GetMessages(2)) except Exception as e: print (e[0]) if __name__ == '__main__': main()
SDE Connection File DOES NOT EXIST : Database Connections\ORCL - SDE@SERVER.sde SDE Connection File EXISTS : Database Connections\ORCL1 - SDE@SERVER1.sde # of Feature Datasets in this workspace : 9 # of Standalone Feature Classes in this workspace : 43 SDE Connection File EXISTS : Database Connections\ORCL2 - SDE@SERVER2.sde # of Feature Datasets in this workspace : 5 # of Standalone Feature Classes in this workspace : 13 SDE Connection File EXISTS : Database Connections\ORCL3 - SDE@SERVER3.sde # of Feature Datasets in this workspace : 10 # of Standalone Feature Classes in this workspace : 27 COMPLETED!!
You could try something like this to format your connection string:
EditorList = ['user1', 'user2', 'user3'] SDEConnect = 'Database Connections\\Atlas2013 {0} as {0}.sde\\sde.CHELAN.LandBase\\sde.CHELAN.Property_Polygons' #Print single user connection print SDEConnect.format(EditorList[1]) #Print all users connection information for editor in EditorList: print SDEConnect.format(editor)
Results:
Database Connections\Atlas2013 user1 as user1.sde\sde.CHELAN.LandBase\sde.CHELAN.Property_Polygons Database Connections\Atlas2013 user2 as user2.sde\sde.CHELAN.LandBase\sde.CHELAN.Property_Polygons Database Connections\Atlas2013 user3 as user3.sde\sde.CHELAN.LandBase\sde.CHELAN.Property_Polygons