Robert,
Thank you again, for available to reply. I got the below Python code.
But It has this error message when executing "Error 000837: The workspace is not the correct workspace type. Failed to execute<Compress>". The SDE connection file is from the folder that ArcCatalog uses to connect. See attached screen copy of connection in arcCatalog. I am stuck here 😞
Thank you very much....
---------------------------------------------------------------------------
# Import system, Geoprocessing, time and email modules
import sys, string, os, arcgisscripting, time
# Set the date.
Date = time.strftime("%m-%d-%Y", time.localtime())
# Set the time.
Time = time.strftime("%I:%M:%S %p", time.localtime())
# Create the Geoprocessor object
gp = arcgisscripting.create()
##gp.CheckProduct("ArcEditor") # Checks the license level.
##gp.SetProduct("ArcEditor") # Sets the license level.
#Process: Check out the highest license available
try:
if gp.CheckProduct("ArcView") == "Available":
gp.SetProduct("ArcView")
elif gp.CheckProduct("ArcEditor") == "Available":
gp.SetProduct("ArcEditor")
elif gp.CheckProduct("ArcInfo") == "Available":
gp.SetProduct("ArcInfo")
except:
message = "ERROR: Could not select an ArcGIS license level! Exiting script..."; showPyError(); sys.exit()
message = "Selected an " + gp.ProductInfo() + " license"; showPyMessage()
print "Process started at " + str(Date) + " " + str(Time) + "." + "\n"
# Set up the log file.
LogFile = file('C:\\temp\\Analyze\\GIS-' + Date + '.txt', 'w') #Creates a log file with todays date.
output = open('C:\\temp\\Analyze\\GIS-' + Date + '.txt', 'w') #Path to log file.
output.write(str("Process started at " + str(Date) + " " + str(Time) + "." + "\n")) # Write the start time to the log file.
# Load required toolboxes (This shouldn't need to be changed unless ArcGIS was
# installed to a different location)
gp.AddToolbox("C:/Program Files (x86)/ArcGIS/Desktop10.1/ArcToolbox/Toolboxes/Data Management Tools.tbx")
try:
# Compress the database
print "Begining Compress..." + "\n"
gp.toolbox = "management"
# For this script to work it will need the full path to the .sde connection file.
gp.compress("C:\Documents and Settings\Administrator\Application Data\ESRI\Desktop10.1\ArcCatalog\Connection to chester_sqlexpress.sde")
print gp.GetMessages() + "\n"
output.write(gp.GetMessages()+ "\n")
except:
Text = gp.GetMessages()
#Display message
print Text
# Sets the Date & Time since the script started.
Date = time.strftime("%m-%d-%Y", time.localtime())# Set the date.
Time = time.strftime("%I:%M:%S %p", time.localtime()) # Set the time.
output.write(str("Process completed at " + str(Date) + " " + str(Time) + "." + "\n")) # Write the start time to the log file.
output.close() # Closes the log file.
print "Process completed at " + str(Date) + " " + str(Time) + "."