Has anyone tried to list the different GIS connections in the catalog side window using python?
I want to run a little script that lists all my ArcGIS, WMS, etc connections, so I can share it with colleagues.
I did some research and found nothing.
Can you point me in the right direction?
The examples below are for SQL Server and Oracle, but others will be similar:
Manage connections in SQL Server—Help | ArcGIS for Desktop
Manage connections in Oracle—Help | ArcGIS for Desktop
You can also directly query the Process_information table in the database, which will also provide the list of active connections.
Those connections are physically stored under C:\Users\<username>\AppData\Roaming\ESRI\Desktop<version>\ArcCatalog, so you can loop through the contents of that folder to find what you need.
Well, after reading Jonathan's reply, I re-read the question and looks like you were not asking for a way to list the active connections to an Enterprise geodatabase. Rather the GIS connections on a particular machine. That was a hurried response on my part.
If I understand correctly, looping through the contents of the folder will just give the name. Or it can list the properties as well through some functions?
Only the names, unfortunately. The arcpy.Describe function can return workspace properties for an SDE connection, but nothing currently exists for GIS connections.
Probably not the way to do it, ... but you could do this:
def main(): import os import glob fldr_user = os.path.join(os.path.expanduser('~'), 'AppData\Roaming\ESRI') lst_desktop = glob.glob(os.path.join(fldr_user,'Desktop*')) fldr_desktop = sorted(lst_desktop)[len(lst_desktop)-1] fldr_catalog = os.path.join(fldr_desktop, "ArcCatalog") print fldr_user print fldr_desktop print fldr_catalog wildcards = ['*.sde', '*.ags', '*.wms'] for wildcard in wildcards: print wildcard lst_conn = glob.glob(os.path.join(fldr_catalog, wildcard)) for conn in lst_conn: print conn if __name__ == '__main__': main()
In my case with 10.3 installed at home it returns this:
C:\Users\Xander\AppData\Roaming\ESRI C:\Users\Xander\AppData\Roaming\ESRI\Desktop10.3 C:\Users\Xander\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog *.sde C:\Users\Xander\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\PROD.sde *.ags C:\Users\Xander\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\arcgis on epm-app25 (user) (2).ags C:\Users\Xander\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\arcgis on epm-app25 (user).ags C:\Users\Xander\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\arcgis on geo.molg.pna.ps_6080 (user).ags C:\Users\Xander\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\arcgis on imagery.arcgisonline.com (user).ags C:\Users\Xander\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\arcgis on mapas.catastrobogota.gov.co (user).ags C:\Users\Xander\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\ArcGIS on sampleserver1.arcgisonline.com (user).ags C:\Users\Xander\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\ArcGIS on sampleserver3.arcgisonline.com (user).ags C:\Users\Xander\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\ArcGIS on server.arcgisonline.com (user).ags C:\Users\Xander\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\arcgis on www.medellin.gov.co (user).ags C:\Users\Xander\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\saint on sagisservices.thempc.org (user).ags *.wms C:\Users\Xander\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\Specialty_ESRI_StatesCitiesRivers_USA on sampleserver1.arcgisonline.wms
There are probably more searches (wildcards) you could include.
As Jonathan mentioned, they are all physically in C:\Users\<username>\AppData\Roaming\ESRI\Desktop<version>\ArcCatalog unless you have connections in non-default folders.
Why not just copy and paste? Is there a reason you need it in a script? You can copy them to a shared network location and write a simple script to copy and paste to their Roaming file, or just have them share them from that location. Just giving an alternative.
I thank you kindly for the answers.
I didnt know the links were in a folder stored. This would have made my life easier.
Now I will test it (when I'm back on this project).