<?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 Cannot Disconnect from an SDE Database using python geoprocessing scripts? in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/cannot-disconnect-from-an-sde-database-using/m-p/657755#M37247</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;9.3sp1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In ArcCatalog, to disconnect from an SDE database, one simply right-clicks on the connection file and chooses disconnect. The database is closed and the .sde file goes back to having a red mark next to it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have not been able to achieve the same functionality using the python geoprocessing environment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code basically looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp = arcgisscripting.create(9.3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;connection = ('/path/to/connection.sde')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.workspace = connection&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# do some stuff&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# when done doing some stuff, try to disconnect:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.ClearWorkspaceCache(connection)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.workspace = ""&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp = None&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Even when the script cleanly exists, the connection remains active. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When I loop through dozens of databases, none of them disconnect and I have dozens of hung connections to dozens of sde databases, and users complaining that I have an active connection to their database, and ask me to please disconnect from it. I've had to tell them that I can't.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ideas?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Apr 2011 15:02:08 GMT</pubDate>
    <dc:creator>SteveWalker3</dc:creator>
    <dc:date>2011-04-15T15:02:08Z</dc:date>
    <item>
      <title>Cannot Disconnect from an SDE Database using python geoprocessing scripts?</title>
      <link>https://community.esri.com/t5/data-management-questions/cannot-disconnect-from-an-sde-database-using/m-p/657755#M37247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;9.3sp1&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In ArcCatalog, to disconnect from an SDE database, one simply right-clicks on the connection file and chooses disconnect. The database is closed and the .sde file goes back to having a red mark next to it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have not been able to achieve the same functionality using the python geoprocessing environment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code basically looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp = arcgisscripting.create(9.3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;connection = ('/path/to/connection.sde')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.workspace = connection&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# do some stuff&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# when done doing some stuff, try to disconnect:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.ClearWorkspaceCache(connection)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.workspace = ""&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp = None&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Even when the script cleanly exists, the connection remains active. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When I loop through dozens of databases, none of them disconnect and I have dozens of hung connections to dozens of sde databases, and users complaining that I have an active connection to their database, and ask me to please disconnect from it. I've had to tell them that I can't.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ideas?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Apr 2011 15:02:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/cannot-disconnect-from-an-sde-database-using/m-p/657755#M37247</guid>
      <dc:creator>SteveWalker3</dc:creator>
      <dc:date>2011-04-15T15:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot Disconnect from an SDE Database using python geoprocessing scripts?</title>
      <link>https://community.esri.com/t5/data-management-questions/cannot-disconnect-from-an-sde-database-using/m-p/657756#M37248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The doc on ClearWorkspaceCache says "Note: Clearing an ArcSDE workspace from the &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ArcSDE workspace cache does not guarantee the connection to the ArcSDE server will &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;be disconnected..."&amp;nbsp; The example shows using env.workspace = "" *before* &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.ClearWorkspaceCache(), so I'd suggest:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Courier New;"&gt;# when done doing some stuff, try to disconnect:&lt;BR /&gt;gp.workspace = ""&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family:Courier New;"&gt;gp.ClearWorkspaceCache(connection)&lt;BR /&gt;gp = None&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- V&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Apr 2011 15:31:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/cannot-disconnect-from-an-sde-database-using/m-p/657756#M37248</guid>
      <dc:creator>VinceAngelo</dc:creator>
      <dc:date>2011-04-15T15:31:18Z</dc:date>
    </item>
  </channel>
</rss>

