<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get list of database connections in arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/get-list-of-database-connections-in-arcpy/m-p/1229421#M66044</link>
    <description>&lt;P&gt;If I was looking for a list of SDE connection in the workspace I would do it this way&lt;/P&gt;&lt;P&gt;import arcpy, os&lt;BR /&gt;ROOT_DIR = os.path.dirname(arcpy.env.workspace)&lt;BR /&gt;for file in os.listdir(ROOT_DIR):&lt;BR /&gt;if file.endswith(".SDE"):&lt;BR /&gt;print(file)&lt;/P&gt;</description>
    <pubDate>Tue, 08 Nov 2022 05:32:35 GMT</pubDate>
    <dc:creator>WilliamChandler</dc:creator>
    <dc:date>2022-11-08T05:32:35Z</dc:date>
    <item>
      <title>Get list of database connections in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/get-list-of-database-connections-in-arcpy/m-p/1112337#M62839</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;I want to get list of my database connections (see pic.)&amp;nbsp; in Arcpy to display them in my tool dropdown list, i try next code:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;workspaces = arcpy.ListWorkspaces("*", "SDE")
    for workspace in workspaces:
        print workspace&lt;/LI-CODE&gt;&lt;P&gt;but it does not give any result.&amp;nbsp; How can i do that?&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 352px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/26450i07099D017A3C13D8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 07:02:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-list-of-database-connections-in-arcpy/m-p/1112337#M62839</guid>
      <dc:creator>Vakhtang_Zubiashvili</dc:creator>
      <dc:date>2021-10-29T07:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Get list of database connections in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/get-list-of-database-connections-in-arcpy/m-p/1112348#M62840</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/listworkspaces.htm" target="_blank"&gt;ListWorkspaces—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;what did the print statement produce?&lt;/P&gt;&lt;P&gt;where in your code did you set your workspace to start the search?&lt;/P&gt;&lt;P&gt;&lt;EM&gt;The workspace environment must be set before using several of the list functions, including ListDatasets, ListFeatureClasses, ListFiles, ListRasters, ListTables, and &lt;STRONG&gt;ListWorkspaces&lt;/STRONG&gt;.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 08:20:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-list-of-database-connections-in-arcpy/m-p/1112348#M62840</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-10-29T08:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: Get list of database connections in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/get-list-of-database-connections-in-arcpy/m-p/1112353#M62841</link>
      <description>&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1) Question: what did the print statement produce?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Answer: &lt;EM&gt;Print statement&amp;nbsp;should produce list of database connections i have in &lt;STRONG&gt;TOC. (See pic. please)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 200px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/26452iB2243868B6583F5A/image-size/small?v=v2&amp;amp;px=200" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2) Question: where in your code did you set your workspace to start the search?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Answer: &lt;EM&gt;I set workspace&amp;nbsp;at the beginning&amp;nbsp;of my code, after &lt;STRONG&gt;Import arcpy&lt;/STRONG&gt; and &lt;STRONG&gt;import os.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I might on wrong way and try to achieve&amp;nbsp;wrong result, but i thought this is a right way :(.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 09:03:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-list-of-database-connections-in-arcpy/m-p/1112353#M62841</guid>
      <dc:creator>Vakhtang_Zubiashvili</dc:creator>
      <dc:date>2021-10-29T09:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Get list of database connections in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/get-list-of-database-connections-in-arcpy/m-p/1112490#M62843</link>
      <description>&lt;P&gt;You will need to post the code that show that and the actual workspace so one can assess whether your database connections are associated with it&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 18:08:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-list-of-database-connections-in-arcpy/m-p/1112490#M62843</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-10-29T18:08:58Z</dc:date>
    </item>
    <item>
      <title>Re: Get list of database connections in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/get-list-of-database-connections-in-arcpy/m-p/1112525#M62844</link>
      <description>&lt;P&gt;Hello, for me all me SDE connections are in the same folder (workspace) so if you define the workspace, you should get your listing of SDE databases. Worked for me. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; (in Catalog, right click the SDE connection, select properties and look at the path of the "name")&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

arcpy.env.workspace = r"C:\Users\USERNAME\AppData\Roaming\ESRI\Desktop10.8\ArcCatalog"

# List all file geodatabases in the current workspace
workspaces = arcpy.ListWorkspaces("*", "SDE")

for workspace in workspaces:
    print workspace&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Oct 2021 19:23:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-list-of-database-connections-in-arcpy/m-p/1112525#M62844</guid>
      <dc:creator>DominicRobergeIADOT</dc:creator>
      <dc:date>2021-10-29T19:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Get list of database connections in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/get-list-of-database-connections-in-arcpy/m-p/1229421#M66044</link>
      <description>&lt;P&gt;If I was looking for a list of SDE connection in the workspace I would do it this way&lt;/P&gt;&lt;P&gt;import arcpy, os&lt;BR /&gt;ROOT_DIR = os.path.dirname(arcpy.env.workspace)&lt;BR /&gt;for file in os.listdir(ROOT_DIR):&lt;BR /&gt;if file.endswith(".SDE"):&lt;BR /&gt;print(file)&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 05:32:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-list-of-database-connections-in-arcpy/m-p/1229421#M66044</guid>
      <dc:creator>WilliamChandler</dc:creator>
      <dc:date>2022-11-08T05:32:35Z</dc:date>
    </item>
  </channel>
</rss>

