Data Management Tools/Geodatabase Administration/ Compress tool in Python

1541
4
12-12-2013 09:09 AM
HectorChapa
Occasional Contributor II
Under Systems toolboxes/Data Management Tools/Geodatabase Administration/Compress tool. Is there a way to recreate this tool in python so it can compress the geodatabase enterprise every week. Any help in finding this in arcpy.

would the following script be the python for this tool


import arcpy
 
arcpy.Compress_management("Database Connections\Connection to brockville.sde")
Tags (2)
0 Kudos
4 Replies
JakeSkinner
Esri Esteemed Contributor
0 Kudos
WilliamCraft
MVP Regular Contributor
You could do this in Python, but you really don't have to.  Another route to go would be to set up a Windows batch file with SDE command line and run it as a scheduled task; then have it email you the results.  For example, try something like this (assumes Oracle but you could modify for SQL Server):

sqlplus sde/sde@database @c:\scripts\lineages_report.sql
sdeversion -o compress -i esri_production -u sde -p sde -N
sqlplus sde/sde@database @c:\scripts\lineages_report.sql
c:\scripts\rnetmail -t user@email.domain.com -f SDE@servername -s Nightly Compress Report -m c:\scripts\lineages_report.txt -x smtp.domain.int


Lines 1 and 3 run a separate SQL script against the database to grab the current state ID for BEFORE and AFTER the compress and then spit those numbers out to a text file.  Line 2 performs the compress.  Line 4 would be where you'd send the email containing the info from the text file; in this example I'm showing the use of a utility called RNETMAIL but there are plenty of options for this.  We follow a procedure like this and, each night after the compress finishes, we get an email showing us how much the lineage got crunched.  One thing to remember, however, is that the SDE command line tools will eventually be deprecated after the next release of ArcGIS.
0 Kudos
collindegueurce
New Contributor III

This is something I am a little confused on...

Don't you actually need to also reconcile/post outstanding edits and then delete user versions -> compress -> recreate user versions -> update statistics

I have been looking for a python script that will actually do this full compress workflow but so far have only found pieces.

Any insight to this would be appreciated!

0 Kudos
collindegueurce
New Contributor III

Actually William Craft you already answered the question at the link below.

https://community.esri.com/message/86698#86698

Just found that. Thanks!

0 Kudos