Disconnect from SDE

2357
2
06-18-2014 01:09 PM
DavidWatkins2
New Contributor II
I am working in an enterprise geodatabase in through Citrix - both the desktop client and SDE are at 10.1.

I often have multiple SDE connections open and would like a way to close all of them at once rather than right clicking on each one and selecting disconnect. I don't see any close or disconnect methods and the arcpy.ClearWorkspaceCache_Management() method does not close the connection in the ArcCatalog tree.

Does anyone know if there is a way to do this using Python?


Thank you
Tags (2)
0 Kudos
2 Replies
PaulSchneider
Occasional Contributor
Something like this maybe?

import arcpy

connectionFile = r"<path\to>\connection.sde"

#block new connections to the database.
arcpy.AcceptConnections(connectionFile, False)

#disconnect all users from the database.
arcpy.DisconnectUser(connectionFile, "ALL")

# do work here

#allow new connections to the database.
arcpy.AcceptConnections(connectionFile, True)
0 Kudos
markdenil
Occasional Contributor III
arcpy.DisconnectUser() disconnects other users, not the current administrative user.

It would, I suppose, be possible to use an administrative connection to disconnect non-administrative connection,
but that only works (if it does at all in this scenario) if the user is an administrative user

It would be good to have a way to disconnect oneself from an SDE database:
one can do it interactively in ArcCatalog....
0 Kudos