AnsweredAssumed Answered

Trouble Running Geodatabase Compress as Python Script

Question asked by pmckinneyccpa on May 27, 2020
Latest reply on May 28, 2020 by jborgion

I have had a Python 2/ArcMap script to compress enterprise geodatabases.  The script has worked fine for a while now.  I recently converted the script to Python 3/ArcGIS Pro. Now, I keep getting the same error (see below).  I've tried referencing the sde connection files using os.path.join and as a single variable (drive/letter/file). I'm looping through a list of geodatabases.

 

Error: Failed to execute. Parameters are not valid.
ERROR 000837: The workspace is not the correct workspace type.
Failed to execute (Compress).

FILE: compress_geodatabases.py, LINE: 41

"arcpy.management.Compress(gdb[0])": Failed to execute. Parameters are not valid.
ERROR 000837: The workspace is not the correct workspace type.
Failed to execute (Compress).

Error compressing CCGIS.sde

 

 

# compress geodatabases
    for gdb in geodatabases:
        try:
            # start time for compress
            start_time_compress = time.perf_counter()
            # compress tool
            arcpy.management.Compress(gdb[0])
            # end time for compress
            end_time_compress = time.perf_counter()
            # elapsed time compress
            elapsed_time_compress = end_time_compress - start_time_compress
            # round elapsed time
            elapsed_time_compress_rounded = round(elapsed_time_compress, 2)
            # add message
            log_message += '\nCompressed {} in {}-seconds\n'.format(gdb[1], elapsed_time_compress_rounded)
        except EnvironmentError as e:
            log_message += print_errors.print_exception(e)
            log_message += '\nError compressing {}\n'.format(gdb[1])
        except Exception as e:
            log_message += print_errors.print_exception(e)
            log_message += '\nError compressing {}\n'.format(gdb[1])
    # end for in

Outcomes