AnsweredAssumed Answered

How do I reestablish a database connection after compressing in a script?

Question asked by henry.bernberg@phila.gov_phl on May 30, 2019
Latest reply on May 30, 2019 by Michael.Romankiewicz@phila.gov_phl

I have a script that needs to run a database compression in the middle so that I can run a SQL update statement. I allow new connections again after the compression, but the script fails because it can't see the database any longer. Is there any way to force the script to reconnect to the database after?

 

Here's a sample of the code. The first Exists shows the feature class is there, but the second one can't see it.

 

if arcpy.Exists(ACCOUNTS):
   print "ACCOUNTS exists"
else: print "ACCOUNTS doesn't exist"

 

arcpy.AcceptConnections(SDE_Connection, False)
arcpy.DisconnectUser(SDE_Connection, "ALL")
arcpy.Compress_management(SDE_Connection)
arcpy.AcceptConnections(SDE_Connection, True)

 

if arcpy.Exists(ACCOUNTS):

   print "ACCOUNTS exists"
else: print "ACCOUNTS doesn't exist"

Outcomes