Gracias por indicarme la dirección correcta. Aquí está el script de ArcPy que escribí y que me funcionó:
#-------------------------------------------------------------------------------
# Name: RemoveSdeObjects.py
# Purpose: Removes all feature datasets, classes and tables for a given user
#
# Author: Andy Arismendi
# Created: 23/06/2011
#-------------------------------------------------------------------------------
#!/usr/bin/env python
from optparse import OptionParser
import sys
import os.path
import arcpy
from arcpy import env
def RemoveAllSdeObjects (workspace, user):
import arcpy
from arcpy import env
env.overwriteOutput = True
env.workspace = workspace
try:
datasetList = arcpy.ListDatasets((user + ".*"), "All")
# Check if the connection failed.
# Look for message: 'WARNING 000565: Could not connect to server.'
connMsg = arcpy.GetMessage(2)
if ('WARNING 000565:' in connMsg):
raise Exception(connMsg)
for dataset in datasetList:
arcpy.Delete_management(dataset)
featureClassList = arcpy.ListFeatureClasses((user + ".*"), "All")
for featureClass in featureClassList:
arcpy.Delete_management(featureClass)
tableList = arcpy.ListTables((user + ".*"), "All")
for table in tableList:
arcpy.Delete_management(table)
except:
raise Exception(arcpy.GetMessages() + "\n")
finally:
env.workspace = ""
def main():
# Process parameters.
try:
usage = "usage: %prog [options]"
parser = OptionParser(usage=usage)
parser.add_option(
"-s", action="store", type="string", dest="server",
help="The SDE server name or IP address.")
parser.add_option(
"-i", action="store", type="int", dest="port",
help="The SDE instance port number.")
parser.add_option(
"-u", action="store", type="string", dest="username",
help="The schema owner username.")
parser.add_option(
"-p", action="store", type="string", dest="password",
help="The schema owner password.")
(options, args) = parser.parse_args()
# All parameters are required.
if options.server == None:
parser.error("Missing required parameter: '-s SDE_SERVER'.")
if options.port == None:
parser.error("Missing required parameter: '-i SDE_PORT'.")
if options.username == None:
parser.error("Missing required parameter: '-u SCHEMA_OWNER_USERNAME'.")
if options.password == None:
parser.error("Missing required parameter: '-p SCHEMA_OWNER_PASSWORD'.")
except:
parser.print_help()
sys.exit(1)
try:
sdeConnectionFileDir = os.environ.get("TEMP")
if sdeConnectionFileDir == None:
raise Exception("Required environment variable is not defined: 'TEMP'.")
databaseName = ""
fileName = options.username + " to " + options.server + ".sde"
# Delete any pre-existing SDE connection file.
fullPath = sdeConnectionFileDir + '\\' + fileName
if os.path.exists(fullPath):
os.remove(fullPath)
# Create temporary SDE connection file.
try:
arcpy.CreateArcSDEConnectionFile_management (
sdeConnectionFileDir, fileName,
options.server, options.port, options.server,
"DATABASE_AUTH", options.username, options.password,
"SAVE_USERNAME",
"SDE.DEFAULT", "SAVE_VERSION"
)
except:
raise Exception(arcpy.GetMessages() + "\n")
# Remove all SDE objects owned by this user.
RemoveAllSdeObjects(fullPath, options.username)
# Remove temporary SDE connection file.
os.remove(fullPath)
except Exception as e:
print "Failed to remove SDE objects.", e
sys.exit(1)
if __name__ == '__main__':
main()