Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a script for updating some features on my database every night (just for copying and replacing some features). This features are "read-only". My problem is that I can't avoid that these features are opened by users, and my script can show the following error:

ExecuteError: ERROR 000464: Cannot get exclusive schema lock. 
              Either being edited or in use by another application.

Can I force the phyton script, via some command, copying the files, even been opened by some user? Can I fall down all the connections on my database before running the script?

share|improve this question
This appears to be an arcpy/arcgisscripting error. Please confirm which you are using, and also which database you are using. – blah238 Jul 5 '12 at 14:31

I suppose that you are working with SDE.

You should kill all connections using sdemon command-line tool.

  1. If there is an ArcSDE installed on PC where you a running the script then you can execute sdemon -o kill locally to kill all connections. Take a look at this help topic. I am not sure is it killing direct-connections on 10.0. I remember that it was a kind of a problem on 9.3 and that it is definitely killing direct-connections on 10.1.
  2. If you don't have ArcSDE installed and it is running only on a separate server then you can execute this command remotely from Python. There is some discussion in this topic.
share|improve this answer
Yes, I'm using SDE (installed on a server). But the "sdemon -o kill" command returned a syntax error. – Arthur Vrechi Jul 5 '12 at 16:37
The sdemon command has to be executed in ArcSDE. Can I put it on my Python script? – Arthur Vrechi Jul 5 '12 at 18:17
Take a look at subprocess module. Also there is nice questions here: How to call external command in Python and Running shell command from python and capturing the output. – Alex Markov Jul 5 '12 at 19:12
Command sdemon -o kill is not enough. You should pass additional parameters, take a look at provided link. – Alex Markov Jul 5 '12 at 19:15

Another possibility since you said you are using SDE is to delete shared locks from the layer_locks and table_locks tables using SQL, PL/SQL, T-SQL, etc. e.g.:


I would definitely not recommend this approach on a versioned geodatabase. See also: How are the various lock mechanisms implemented in ArcSDE and the geodatabase?

share|improve this answer

I'm not very familiar with postgresql but I think this post can lead you to the right direction:

share|improve this answer

If the preference is to remove specific SDE user locks, there is a way to do this via arcpy. I prefer this approach because it doesn't require that you jump onto the database server to perform an sde command. I can disconnect any unwanted locks, then perform data updates all in one script/process.

Example from the above link is very useful:

import arcpy

admin_workspace = "Database Connections/tenone@sde.sde"
arcpy.env.workspace = admin_workspace
user_name = "GDB"

# Look through the users in the connected user list and get the SDE ID.
# Use the SDE ID to disconnect the user that matches the username variable
users = arcpy.ListUsers() # The environment is set, no workspace is needed.
for item in users:
    if item.Name == user_name:
        arcpy.DisconnectUser(admin_workspace, item.ID)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.