Select to view content in your preferred language

Python script to reconcile enterprise database version to default is not working

599
3
Jump to solution
10-18-2024 08:54 AM
GeorgeJonesRIGOV
Occasional Contributor

Hi all, I'm trying to reconcile a checked out enterprise database to the default database version. Here is the code I have so far but does not work.

import arcpy
from arcpy import env
arcpy.env.overwriteOutput = True
arcpy.env.workspace =r'S:\PW\GIS\Map Requests\2023_07_YardWasteAprxProjectAndRefuseRoutes\xxxxxx03_PW_Edit.sde'
arcpy.ReconcileVersions_management (arcpy.env.workspace, "ALL_VERSIONS", "DBO.DEFAULT", "versionlist", "LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_EDIT_VERSION", "POST", "KEEP_VERSION", "reconcileLog")
fc = r'S:\PW\GIS\Map Requests\2023_07_YardWasteAprxProjectAndRefuseRoutes\xyzxyzx.sde\xyzxy.DBO.Routes\xyzxy.DBO.YardWasteRoutesBest2024'
arcpy.management.MakeFeatureLayer(fc, 'YardWasteStops','','')
arcpy.ChangeVersion_management('YardWasteStops','TRANSACTIONAL', 'DBO.xxEdit','')
arcpy.conversion.FeatureClassToFeatureClass('YardWasteStops',r'S:\xy\GIS\Map Requests\2023_07_YardWasteAprxProjectAndRefuseRoutes\YardwasteAprx.gdb','YardWasteStops')
print('done')

 

As a result, I keep getting a log file saying "Warning: The reconcile process was not performed. The specified target version (dbo.DEFAULT) has no edit versions to reconcile with". This should not be the case. The dbo.DEFAULT is the parent version and the PW_Edit is the child version of this.  I am stumped as why is that the case.

Note i replaced the file path names with xyxyx for privacy.

0 Kudos
1 Solution

Accepted Solutions
TonyAlmeida
MVP Regular Contributor

Make sure DBO.PW_Edit exists. Also, make sure that the child version you are attempting to reconcile with DBO.DEFAULT is correct. Try this.

 

import arcpy

# Set workspace to the geodatabase
arcpy.env.workspace = r'S:\PW\GIS\Map Requests\2023_07_YardWasteAprxProjectAndRefuseRoutes\xxxxxx03_PW_Edit.sde'
arcpy.env.overwriteOutput = True

# List all versions to verify the child version exists
versions = arcpy.da.ListVersions(arcpy.env.workspace)
for version in versions:
    print(version.name)

# Reconcile the child version "PW_Edit" with the parent "DBO.DEFAULT"
child_version = "PW_Edit"
try:
    arcpy.ReconcileVersions_management(
        arcpy.env.workspace,
        "ALL_VERSIONS",
        "DBO.DEFAULT",
        child_version,  # Ensure the correct child version name is provided
        "LOCK_ACQUIRED",
        "NO_ABORT",
        "BY_OBJECT",
        "FAVOR_EDIT_VERSION",
        "POST",
        "KEEP_VERSION",
        r'S:\PW\GIS\Map Requests\2023_07_YardWasteAprxProjectAndRefuseRoutes\reconcileLog.txt'  # Log file path
    )
    print("Reconciliation successful.")
except Exception as e:
    print(f"Reconciliation failed: {e}")

# After reconciliation
fc = r'S:\PW\GIS\Map Requests\2023_07_YardWasteAprxProjectAndRefuseRoutes\xyzxyzx.sde\xyzxy.DBO.Routes\xyzxy.DBO.YardWasteRoutesBest2024'
arcpy.management.MakeFeatureLayer(fc, 'YardWasteStops', '', '')
arcpy.ChangeVersion_management('YardWasteStops', 'TRANSACTIONAL', 'DBO.PW_Edit', '')
arcpy.conversion.FeatureClassToFeatureClass(
    'YardWasteStops',
    r'S:\xy\GIS\Map Requests\2023_07_YardWasteAprxProjectAndRefuseRoutes\YardwasteAprx.gdb',
    'YardWasteStops'
)
print('done')

 

View solution in original post

0 Kudos
3 Replies
TonyAlmeida
MVP Regular Contributor

Make sure DBO.PW_Edit exists. Also, make sure that the child version you are attempting to reconcile with DBO.DEFAULT is correct. Try this.

 

import arcpy

# Set workspace to the geodatabase
arcpy.env.workspace = r'S:\PW\GIS\Map Requests\2023_07_YardWasteAprxProjectAndRefuseRoutes\xxxxxx03_PW_Edit.sde'
arcpy.env.overwriteOutput = True

# List all versions to verify the child version exists
versions = arcpy.da.ListVersions(arcpy.env.workspace)
for version in versions:
    print(version.name)

# Reconcile the child version "PW_Edit" with the parent "DBO.DEFAULT"
child_version = "PW_Edit"
try:
    arcpy.ReconcileVersions_management(
        arcpy.env.workspace,
        "ALL_VERSIONS",
        "DBO.DEFAULT",
        child_version,  # Ensure the correct child version name is provided
        "LOCK_ACQUIRED",
        "NO_ABORT",
        "BY_OBJECT",
        "FAVOR_EDIT_VERSION",
        "POST",
        "KEEP_VERSION",
        r'S:\PW\GIS\Map Requests\2023_07_YardWasteAprxProjectAndRefuseRoutes\reconcileLog.txt'  # Log file path
    )
    print("Reconciliation successful.")
except Exception as e:
    print(f"Reconciliation failed: {e}")

# After reconciliation
fc = r'S:\PW\GIS\Map Requests\2023_07_YardWasteAprxProjectAndRefuseRoutes\xyzxyzx.sde\xyzxy.DBO.Routes\xyzxy.DBO.YardWasteRoutesBest2024'
arcpy.management.MakeFeatureLayer(fc, 'YardWasteStops', '', '')
arcpy.ChangeVersion_management('YardWasteStops', 'TRANSACTIONAL', 'DBO.PW_Edit', '')
arcpy.conversion.FeatureClassToFeatureClass(
    'YardWasteStops',
    r'S:\xy\GIS\Map Requests\2023_07_YardWasteAprxProjectAndRefuseRoutes\YardwasteAprx.gdb',
    'YardWasteStops'
)
print('done')

 

0 Kudos
GeorgeJonesRIGOV
Occasional Contributor

thank you ! That worked! Saves me a lot of time.

0 Kudos
TonyAlmeida
MVP Regular Contributor

Glad it worked for you!

0 Kudos