0

Putting together a scripted event where we update user-schema (prod) in one sde instance from a dev user-schema instance. Both sdes are Oracle 12c. Replication is not used and the destination objects (6 feature classes and 15 tables) are not versioned. We want to release all locks so that we can delete the objects from our production SDE and copy the same objects from the dev SDE.

Using the admin connection, can I release locks/services at the user-schema level or does it have to be performed at the master level? If so, is the cadence of events below correct?

import os
import arcpy
import datetime

start = datetime.datetime.now()

print 'start run: %s\n' % (start)

#Parameters
prodadmin = r"C:/Users/101Connections/Prod/Admin@Prod.sde" #Prod Admin
faprod = r"C:/Users/101Connections/Prod/Facilities@Prod.sde" #Prod(o)
fadev = r"C:/Users/101Connections/Dev/facilities@Dev.sde" #Dev(i)

fatabs = ["1","2","3"] #FACILITIES tables
fafcls = ["A","B","C"] #FACILITIESs feature classes

arcpy.env.workspace = prodadmin

#Release connections  
users = arcpy.ListUsers()
for user in users:
    print("Username: {0}, Connected at: {1}".format(
        user.Name, user.ConnectionTime))
arcpy.DisconnectUser(faprod, "ALL")
arcpy.AcceptConnections(faprod, False)


#Change workspace for Copy+configuration
arcpy.env.workspace = faprod

#delete tables in faprod. clears out all reclass objects.
try:
    for tb in fatabs:
        if arcpy.Exists(tb):
            arcpy.Delete_management(tb)        
    print "fatabs success!"

except:
    print arcpy.GetMessages(2)

#copy tables from fadev to faprod. exists to catch duplicate objects from 
reclass.
try:
    for tb in fatabs:
        if arcpy.Exists(tb):
            print tb + "Already here!"
        else:
            arcpy.Copy_management(fadev + "/" + tb, faprod + "/" + tb)
            print tb + "Created!"
except:
    print arcpy.GetMessages(2)

print 'finished run: %s\n\n' % (datetime.datetime.now() - start)
0

Fixed it - I had sequenced the disconnects at the master level and change workspace to user schema incorrectly.

users = arcpy.ListUsers(prodadmin)
for user in users:
    print("Username: {0}, Connected at: {1}".format(
    user.Name, user.ConnectionTime))
arcpy.DisconnectUser(prodadmin, "ALL")
print "Users disconnected"

arcpy.env.workspace = faprod

arcpy.AcceptConnections(prodadmin, False)
print "Connections blocked"

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.