Select to view content in your preferred language

Checking SDE Connections for an Edit Session

1258
1
11-21-2017 04:13 PM
by Anonymous User
Not applicable

I am implementing Esri's python script to batch reconcile and post versions of our Enterprise Geodatabase running on SQL Server.  The script is found here and would be run from our server using Task Scheduler.  Instead of automatically disconnecting users from the database after a set period, we would like to check whether a user has an open edit session going.  If there is an active edit session, instead of disconnecting the user and losing any edits they may have made, the script would not be run.

Currently, the script set to run only if there are no other users connected besides the administrator, i.e. if a Map Document is left open overnight on a Desktop the script won't run.  This is a blanket fix and I would prefer that the script still run if the open map document isn’t being actively edited.

Is there a way to check if a user connected to the database is in an edit session?

1 Reply
RebeccaStrauch__GISP
MVP Emeritus

I found this, which may have some things to try

Checking via ArcPy if ArcMap is in edit session? - Geographic Information Systems Stack Exchange 

This may be more of an ArcMap tool, but I'm looking at it too since testing for edit sessions would be handy for me too (right now, I manually use the SDE Database administrator and look for locks).  

I have seen other post tools for running nightly rec/post and compress too, and my guess is they check for edit sessions too.  I don't have one of those thread at my finger tips, but might be worth a search.

My guess is you've already seend the help to get a list of the connected users.

Manage connections in SQL Server—Help | ArcGIS Desktop 

Think I found it......I'm testing and will add a post

EDIT:  this looks like it should work, but I'm getting False even after opening a session.  I am testing against a version SDE with topology.

import arcpy

myConn = r'Database Connections\me@myData.sde'
arcpy.da.Editor(myConn).isEditing

Editor—Help | ArcGIS for Desktop 

btw - I converted you document to a question.  You should get more views/responses.

0 Kudos