<?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: Automated method to check if enterprise geodatabase is accepting connections? in Geodatabase Questions</title>
    <link>https://community.esri.com/t5/geodatabase-questions/automated-method-to-check-if-enterprise/m-p/1125489#M7460</link>
    <description>&lt;P&gt;Take a look at this:&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/acceptconnections.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/acceptconnections.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Looks like it is what you are looking for.&lt;/P&gt;</description>
    <pubDate>Mon, 13 Dec 2021 17:39:11 GMT</pubDate>
    <dc:creator>George_Thompson</dc:creator>
    <dc:date>2021-12-13T17:39:11Z</dc:date>
    <item>
      <title>Automated method to check if enterprise geodatabase is accepting connections?</title>
      <link>https://community.esri.com/t5/geodatabase-questions/automated-method-to-check-if-enterprise/m-p/1125481#M7459</link>
      <description>&lt;P&gt;Our organization has a database maintenance script that runs nightly. Without going into too much detail of the script tasks, the first task is to stop any connections to the GDB and the last step is to open connections back to the GDB. While it is rare, once a blue moon the script will stop during a run and not allow for database connections. We usually find this out when the end users are prompted with an error message the next morning and we have to manually check the box to allow for connections.&amp;nbsp; I should note we do have safeguards in place if the script runs into any geoprocessing errors; the script will send admin users an email message of the error that was encountered and reestablish database connections as a final step. However, there are the strange instances where the script will stop completely with no errors, thus not taking that final step to accept connections.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;My questions is: is there a way using python to check if an enterprise geodatabase is accepting connections?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Ideally I would like to write a simple script that performs the following tasks:&lt;BR /&gt;1. Check if GDB is accepting connections&lt;BR /&gt;2. If yes, end script&lt;BR /&gt;3. If no, send an alert message to admins and accept connections&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 17:19:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/automated-method-to-check-if-enterprise/m-p/1125481#M7459</guid>
      <dc:creator>Brownschuh</dc:creator>
      <dc:date>2021-12-13T17:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Automated method to check if enterprise geodatabase is accepting connections?</title>
      <link>https://community.esri.com/t5/geodatabase-questions/automated-method-to-check-if-enterprise/m-p/1125489#M7460</link>
      <description>&lt;P&gt;Take a look at this:&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/acceptconnections.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/acceptconnections.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Looks like it is what you are looking for.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 17:39:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/automated-method-to-check-if-enterprise/m-p/1125489#M7460</guid>
      <dc:creator>George_Thompson</dc:creator>
      <dc:date>2021-12-13T17:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: Automated method to check if enterprise geodatabase is accepting connections?</title>
      <link>https://community.esri.com/t5/geodatabase-questions/automated-method-to-check-if-enterprise/m-p/1125490#M7461</link>
      <description>&lt;P&gt;Thank you for the reply.&amp;nbsp; We already use the AcceptConnections function to block or accept connections in our database maintenance scripts.&amp;nbsp; What I'm looking for is a way to check if connections are blocked/open.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 17:49:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/automated-method-to-check-if-enterprise/m-p/1125490#M7461</guid>
      <dc:creator>Brownschuh</dc:creator>
      <dc:date>2021-12-13T17:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Automated method to check if enterprise geodatabase is accepting connections?</title>
      <link>https://community.esri.com/t5/geodatabase-questions/automated-method-to-check-if-enterprise/m-p/1125500#M7462</link>
      <description>&lt;P&gt;Ah, you are correct. Sorry I did not fully gather that. I am not sure of a way, but have seen a thread mention it:&amp;nbsp;&lt;A href="https://gis.stackexchange.com/questions/14677/can-arcpy-test-for-availability-of-sde-connection-before-trying-to-use-it" target="_blank"&gt;https://gis.stackexchange.com/questions/14677/can-arcpy-test-for-availability-of-sde-connection-before-trying-to-use-it&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;You may also want to add something like a describe (&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/featureclass-properties.htm_" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/featureclass-properties.htm)&lt;/A&gt;&amp;nbsp; on a specific feature class in the DB to see if it works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 18:15:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/automated-method-to-check-if-enterprise/m-p/1125500#M7462</guid>
      <dc:creator>George_Thompson</dc:creator>
      <dc:date>2021-12-13T18:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: Automated method to check if enterprise geodatabase is accepting connections?</title>
      <link>https://community.esri.com/t5/geodatabase-questions/automated-method-to-check-if-enterprise/m-p/1125605#M7463</link>
      <description>&lt;P&gt;I cannot see arcpy function to test if geodatabase is accepting connections. Quick SQL trace tells me that ArcGIS checks it using following SQL statement&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;SELECT num_prop_value FROM &lt;EM&gt;DBNAME&lt;/EM&gt;.sde.SDE_server_config WHERE prop_name = 'STATUS'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;And if the value is 2, it is NOT accepting connections. Value 1 means it is.&lt;/P&gt;&lt;P&gt;Following python code may help.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;arcpy&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;os&lt;BR /&gt;&lt;SPAN&gt;def &lt;/SPAN&gt;is_accepting_connections(sde_conn_nonadmin):&lt;BR /&gt;    &lt;SPAN&gt;if &lt;/SPAN&gt;(os.path.exists(sde_conn_nonadmin) == &lt;SPAN&gt;False&lt;/SPAN&gt;):&lt;BR /&gt;        &lt;SPAN&gt;raise &lt;/SPAN&gt;&lt;SPAN&gt;ValueError&lt;/SPAN&gt;(&lt;SPAN&gt;"Invalid SDE connection file '{}'"&lt;/SPAN&gt;.format(sde_conn_nonadmin))&lt;BR /&gt;    &lt;SPAN&gt;try&lt;/SPAN&gt;:&lt;BR /&gt;        arcpy.env.workspace = sde_conn_nonadmin&lt;BR /&gt;        desc = arcpy.Describe(sde_conn_nonadmin)&lt;BR /&gt;        &lt;SPAN&gt;if &lt;/SPAN&gt;(&lt;SPAN&gt;hasattr&lt;/SPAN&gt;(desc, &lt;SPAN&gt;'workspaceType'&lt;/SPAN&gt;)):&lt;BR /&gt;            &lt;SPAN&gt;return True&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;        else&lt;/SPAN&gt;:&lt;BR /&gt;            &lt;SPAN&gt;return False&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    except&lt;/SPAN&gt;:&lt;BR /&gt;        &lt;SPAN&gt;raise&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 21:47:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/automated-method-to-check-if-enterprise/m-p/1125605#M7463</guid>
      <dc:creator>VishApte</dc:creator>
      <dc:date>2021-12-13T21:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: Automated method to check if enterprise geodatabase is accepting connections?</title>
      <link>https://community.esri.com/t5/geodatabase-questions/automated-method-to-check-if-enterprise/m-p/1125855#M7464</link>
      <description>&lt;P&gt;Bummer, I was hoping there would be an arcpy function to test if a GDB is accepting connections.&amp;nbsp; Maybe ESRI can include that functionality in future releases?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 14:51:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/automated-method-to-check-if-enterprise/m-p/1125855#M7464</guid>
      <dc:creator>Brownschuh</dc:creator>
      <dc:date>2021-12-14T14:51:06Z</dc:date>
    </item>
  </channel>
</rss>

