<?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: Can you use arcpy to get the database connection type? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/can-you-use-arcpy-to-get-the-database-connection/m-p/1506524#M71086</link>
    <description>&lt;P&gt;We tried this syntax a couple month ago with an .sde-file and it worked. Now I always get the error "DescribeData: Method connectionProperties does not exist". What are possible reasons for this?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jul 2024 09:27:07 GMT</pubDate>
    <dc:creator>nadja</dc:creator>
    <dc:date>2024-07-18T09:27:07Z</dc:date>
    <item>
      <title>Can you use arcpy to get the database connection type?</title>
      <link>https://community.esri.com/t5/python-questions/can-you-use-arcpy-to-get-the-database-connection/m-p/428085#M33628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Anyone know if you can use arcpy to get the database connection type?&amp;nbsp; i.e. Oracle, Application Server, SQL Server, etc. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to find a way to identify all of the Application Server connection files in a series of folders so that I can change them to Oracle Direct Connections.&amp;nbsp; To further clarify, if you look at the connection properties for a Database Connection in ArcCatalog you will see this in the Database Platform combobox.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Aron&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Mar 2015 20:22:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-you-use-arcpy-to-get-the-database-connection/m-p/428085#M33628</guid>
      <dc:creator>AronBird</dc:creator>
      <dc:date>2015-03-26T20:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use arcpy to get the database connection type?</title>
      <link>https://community.esri.com/t5/python-questions/can-you-use-arcpy-to-get-the-database-connection/m-p/428086#M33629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/018v/018v00000030000000.htm"&gt;ListUsers()&lt;/A&gt; has the IsDirectConnection property. I think If it's not direct connect, then it's application server.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Mar 2015 20:34:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-you-use-arcpy-to-get-the-database-connection/m-p/428086#M33629</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-03-26T20:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use arcpy to get the database connection type?</title>
      <link>https://community.esri.com/t5/python-questions/can-you-use-arcpy-to-get-the-database-connection/m-p/428087#M33630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;ListUsers()&lt;/SPAN&gt; is focused on existing/current connections to an SDE database, not SDE connection files on disk, which is what I think the OP is after.&amp;nbsp; I believe the &lt;SPAN style="font-family: courier new,courier;"&gt;connectionProperties&lt;/SPAN&gt; of the &lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-functions/workspace-properties.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Workspace properties&lt;/A&gt; of the &lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-functions/describe.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Describe object &lt;/A&gt;will allow the OP to get the information.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; desc = arcpy.Describe(r'Database Connections\LGDB.sde')
&amp;gt;&amp;gt;&amp;gt; cp = desc.connectionProperties
&amp;gt;&amp;gt;&amp;gt; cp.instance
u'sde:sqlserver:(localdb)\\MSSQLLocalDB'&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For an application server, the instance property will look something like: &lt;SPAN style="font-family: courier new,courier;"&gt;u'5152:SDE'&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:16:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-you-use-arcpy-to-get-the-database-connection/m-p/428087#M33630</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T19:16:01Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use arcpy to get the database connection type?</title>
      <link>https://community.esri.com/t5/python-questions/can-you-use-arcpy-to-get-the-database-connection/m-p/428088#M33631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Blake and Joshua. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, I am trying to find the SDE connection files on disk and not those connected to the database.&amp;nbsp; This does work but unfortunately you have to enter a username and password otherwise it will fail.&amp;nbsp; It would be nice to return a 'Database Platform' value like the screenshot below rather than inferring it is an Application Server connection from the returned instance service number and it would also be nice to not have to connect to the database but either way, I think I can make it work for what I need it to do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Aron&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/79053_pastedImage_1.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Mar 2015 22:10:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-you-use-arcpy-to-get-the-database-connection/m-p/428088#M33631</guid>
      <dc:creator>AronBird</dc:creator>
      <dc:date>2015-03-26T22:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use arcpy to get the database connection type?</title>
      <link>https://community.esri.com/t5/python-questions/can-you-use-arcpy-to-get-the-database-connection/m-p/428089#M33632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since Application Servers are dead at ArcGIS 10.3, I don't think Esri is going to invest anything in making it easier to identify them.&amp;nbsp; The "Database Platform" field you reference is relatively new-ish, starting at ArcGIS 10.1.&amp;nbsp; Although the GUI shows this new field, I don't believe there were any changes with the workspace connection properties data structure on the backend.&amp;nbsp; In the end, returning a Database Platform value would have to be from a function that processes the connection properties and not directly from the connection properties themselves.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You raise an interesting, and annoying, part of processing SDE connection files.&amp;nbsp; I primarily work with operating system authentication, so the issue of having the username/password prompt doesn't usually impact me.&amp;nbsp; That said, it is frustrating that one has to fully authenticate for ArcPy to see any of the connection properties.&amp;nbsp; When working with the GUI, a user can look at several connection properties without having to actually connect to the database.&amp;nbsp; It would be nice to see similar behavior in ArcPy if no username or password are given.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Mar 2015 18:09:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-you-use-arcpy-to-get-the-database-connection/m-p/428089#M33632</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-03-30T18:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use arcpy to get the database connection type?</title>
      <link>https://community.esri.com/t5/python-questions/can-you-use-arcpy-to-get-the-database-connection/m-p/428090#M33633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you are willing to install comtypes, then the SDE connection properties can be extracted without actually connecting to the database.&amp;nbsp; I ginned up the following function, just pass it the SDE connection file and it returns a dictionary with all of the connection properties.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def GetConnectionPropertiesFromFile(in_workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp; from comtypes.client import CreateObject, GetModule
&amp;nbsp;&amp;nbsp;&amp;nbsp; import os
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; comDirectory = os.path.join(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; os.path.join(arcpy.GetInstallInfo()['InstallDir']), 'com'
&amp;nbsp;&amp;nbsp;&amp;nbsp; )
&amp;nbsp;&amp;nbsp;&amp;nbsp; esriDataSourcesGDB = GetModule(os.path.join(comDirectory, 'esriDataSourcesGDB.olb'))
&amp;nbsp;&amp;nbsp;&amp;nbsp; esriGeoDatabase = GetModule(os.path.join(comDirectory, 'esriGeodatabase.olb'))
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; pWSF = CreateObject(esriDataSourcesGDB.SdeWorkspaceFactory,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; interface=esriGeoDatabase.IWorkspaceFactory)
&amp;nbsp;&amp;nbsp;&amp;nbsp; pPropSet = pWSF.ReadConnectionPropertiesFromFile(in_workspace)
&amp;nbsp;&amp;nbsp;&amp;nbsp; names, values = pPropSet.GetAllProperties()
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; connectionProperties = {}
&amp;nbsp;&amp;nbsp;&amp;nbsp; for i in range(len(names)):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; connectionProperties[names&lt;I&gt;] = values&lt;I&gt;&lt;/I&gt;&lt;/I&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; return connectionProperties&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:16:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-you-use-arcpy-to-get-the-database-connection/m-p/428090#M33633</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T19:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Can you use arcpy to get the database connection type?</title>
      <link>https://community.esri.com/t5/python-questions/can-you-use-arcpy-to-get-the-database-connection/m-p/1506524#M71086</link>
      <description>&lt;P&gt;We tried this syntax a couple month ago with an .sde-file and it worked. Now I always get the error "DescribeData: Method connectionProperties does not exist". What are possible reasons for this?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2024 09:27:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-you-use-arcpy-to-get-the-database-connection/m-p/1506524#M71086</guid>
      <dc:creator>nadja</dc:creator>
      <dc:date>2024-07-18T09:27:07Z</dc:date>
    </item>
  </channel>
</rss>

