Hi - i'm fairly new to python, but am working my way through this article Use Python scripting to batch reconcile and post versions—ArcGIS Help | ArcGIS Desktop . I am on the step "Rebuild indexes and update statistics" and I have to set the workspace environment.
# set the workspace
arcpy.env.workspace = "C:\\Projects\\MyProject\\user1.sde"
Where do i find the path like listed above for the gdb Owner? I have enterprise gdbs set up and there is one user who is the db owner. Is this just the sde connection file location? Or can i chose any folder location?
Thanks!
Pamela
You'll need a connection file with the owner creds to do that; depending on how you set up your enterprise (sde) the SDE user is the guy that does that operation as I recall.
here is one i use. Reconcile Versions—Data Management toolbox | Documentation
# Set workspace
arcpy.env.workspace = r'C:\Users\####\AppData\Roaming\ESRI\Desktop10.6\ArcCatalog\Connection to ####.sde'
# Set the workspace environment
workspace = arcpy.env.workspace
# Use a list comprehension to get a list of version names where the owner
# is the current user and make sure sde.default is not selected.
#verList = [ver.name for ver in arcpy.da.ListVersions() if ver.isOwner
# == True and ver.name.lower() != '####']
arcpy.ReconcileVersions_management(workspace,
"ALL_VERSIONS",
"#####",
"#####",
"LOCK_ACQUIRED",
"NO_ABORT",
"BY_OBJECT",
"FAVOR_EDIT_VERSION",
"POST",
"KEEP_VERSION",
"c:\Temp\RecLog.txt")
print ('Reconciling Complete')
You can build the connection on the fly in your code if you like. But it is simplest to just create one ahead of time as Joe suggested.
The python way:
Create Database Connection—Help | ArcGIS for Desktop
Or in ArcCatalog:
- right-click on a folder and select New > Database Connection...
- then you will need the user name and password etc.