Frequently asked question
Python scripts can be used to perform administration tasks on a geodatabase connection, for example, adding logins and managing user access. To connect and disconnect users of the geodatabase, an ArcSDE Connection File is required to act as the geodatabase administrator. The ArcSDE Connection File is created when the Python script starts using the ArcPy function, CreateArcSDEConnectionFile_management(), and the file is saved as an .sde file in the hard drive. For more information, refer to the web help document, ArcGIS Desktop: Create ArcSDE Connection File.
The ArcSDE Connection File contains the geodatabase administration connection properties, holding confidential information such as login credentials. In most cases, it is not recommended to have the SDE file reside in the hard drive since the file and its information are exposed to multiple users.
It is not possible to store the ArcSDE Connection File in the CPU memory because the ArcPy geoprocessing tool used for disconnecting users requires an SDE file as an input. The workaround to prevent the SDE connection file from remaining in the hard drive is to delete the SDE connection file at the end of the Python script. This can be done using the os.remove() Python function.
The following sample demonstrates how to use the os.remove() function.
import arcpy folderName = r"c:\connectionFiles" fileName = "SDE_connection.sde" serverName = "gpserver" SDE_connection = arcpy.CreateArcSDEConnectionFile_management (folderName, fileName, serverName) ... ... os.remove("SDE_connection.sde")
Get help from ArcGIS experts
Download the Esri Support App