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 take down all the connections on my database before running the script?

  • 1
    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.
| improve this answer | |

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?

| 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)
| improve this answer | |
  • I ran this, and seemed to work, until it hit my current sessionID, and threw an error. Is there a way to loop through users and skip the current user (if item.Name == 'DBO' and item.ID != <current user's session ID>)? I cannot find a way to find the current user's session ID. – m.Walker Aug 13 '19 at 20:28

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


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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