I have two geodatabases, one with February data (Final_Project_2.gdb) which contains 6 feature classes. The second geodatabase has March data, (Clipped.gdb), which also contains 6 feature classes, the same ones' as the first one, except some of the feature classes attribute tables have been updated. I have been trying to run the Table Compare tool in ArcGIS Pro, but as a python script, and just can't get it. In reality I just want to get the row count from each table in each feature class from the new database and compare it to the row count of each table in each feature class to the old database and see which feature class was updated/changed, so that the GIS library can be updated accordingly.

I've ran the tool in ArcGIS Pro and can do it one by one, by I would like to do like a loop, and go from GDB1 to GDB2, and if they are == (no change), skip, but if there is a change, print out the Name.



This is a script I tried but got an error:

clippedGBD = r"C:\GIS6340\Final_Project_GIS6340\FC_03132022\ClippedFC\ClippedGDB.gdb"
in_base_table = r"C:\GIS6340\Final_Project_GIS6340\FC_03132022\ClippedFC\ClippedGDB.gdb"
in_test_table = r"C:\GIS6340\Final_Project_2\Final_Project_2.gdb"
sort_field = "OBJECTID"
compare_type = "ALL"
attribute_tolerance = "None"
omit_field = "ALL"
continue_compare = "CONTINUE_COMPARE"
compare_file = "C:\GIS6340\Final_Project_GIS6340\FC_03132022\ClippedFC\Compared.cvs"

compare_result = arcpy.TableCompare_management(
    in_base_table, in_test_table, sort_field, compare_type, ignore_option, 
    attribute_tolerance, omit_field, continue_compare, compare_file)


Traceback (most recent call last):
  File "<string>", line 14, in <module>
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 2023, in TableCompare
    raise e
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 2020, in TableCompare
    retval = convertArcObjectToPythonObject(gp.TableCompare_management(*gp_fixargs((in_base_table, in_test_table, sort_field, compare_type, ignore_options, attribute_tolerances, omit_field, continue_compare, out_compare_file), True)))
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
    return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
 ERROR 000732: Input Base Table: Dataset C:\GIS6340\Final_Project_GIS6340\FC_03132022\ClippedFC\ClippedGDB.gdb does not exist or is not supported
 ERROR 000732: Input Test Table: Dataset C:\GIS6340\Final_Project_2\Final_Project_2.gdb does not exist or is not supported
 ERROR 000893: An empty GP value or text is entered.
Failed to execute (TableCompare).
  • 1
    in_base_table and in_test_table should be tables, you are pointing at the geodatabases
    – Bera
    Commented Mar 29, 2022 at 9:40
  • 2
    For example in_base_table = r"C:\GIS6340\Final_Project_GIS6340\FC_03132022\ClippedFC\ClippedGDB.gdb" should for one table be in_base_table = r"C:\GIS6340\Final_Project_GIS6340\FC_03132022\ClippedFC\ClippedGDB.gdb\Anf_Road_MVUM"
    – Bera
    Commented Mar 29, 2022 at 9:56
  • Yes use ListTables
    – Bera
    Commented Apr 2, 2022 at 15:50
  • @BERA, thank you, I have done it as you suggested but that runs one table at a time. I want to compare all at the same time, via a loop; like this: ANF_AdministrativeRegion = ANF_AdministrativeRegion TRUE/FALSE ANF_RangerDistrict = ANF_RangerDistrict TRUE/FALSE and so forth...
    – Yerce81
    Commented Apr 2, 2022 at 16:03

2 Answers 2


I'll answer this part of your question:

In reality I just want to get the row count from each table in each feature class from the new database and compare it to the row count of each table in each feature class to the old database and see which feature class was updated/changed

You could write a function that takes the geodatabases as inputs and compares the number of features in the corresponding feature classes (and note any feature classes that don't exist in either gdb). Not the cleanest code, but you could do something like:

import arcpy
import os

def compare_gdbs(gdb_1, gdb_2):
    # Turning the list into a set makes comparison easy.
    arcpy.env.workspace = gdb_1
    fcs_1 = set(arcpy.ListFeatureClasses())
    arcpy.env.workspace = gdb_2
    fcs_2 = set(arcpy.ListFeatureClasses())

    fcs_only_in_1 = fcs_1 - fcs_2
    for fc in fcs_only_in_1:
        print(f'{fc} only in {gdb_1}')

    fcs_only_in_2 = fcs_2 - fcs_1
    for fc in fcs_only_in_2:
        print(f'{fc} only in {gdb_2}')

    fcs_in_both = fcs_1.intersection(fcs_2)
    for fc in fcs_in_both:
        fc_path_1 = os.path.join(gdb_1, fc)
        fc_path_2 = os.path.join(gdb_2, fc)

        # GetCount returns a Result object. Make into a number.
        num_features_1 = int(arcpy.management.GetCount(fc_path_1)[0])
        num_features_2 = int(arcpy.management.GetCount(fc_path_2)[0])

        if num_features_1 == num_features_2:
            print(f'{fc} matches feature count')
            print(f'{fc} #1: {num_features_1}, {fc} #2: {num_features_2}')


if __name__ == '__main__':
    gdb_old = r'C:\GIS6340\Final_Project_GIS6340\FC_03132022\ClippedFC\ClippedGDB.gdb'
    gdb_new = r'C:\GIS6340\Final_Project_2\Final_Project_2.gdb'
    compare_gdbs(gdb_old, gdb_new)
  • # Sam Szotkowski, thanks, I will try this and see if it works.
    – Yerce81
    Commented Apr 2, 2022 at 16:05

Try something like this:

import arcpy, os

db1 = r'C:\GIS\data\tempdata\db1.gdb'
db2 = r'C:\GIS\data\tempdata\db2.gdb'

arcpy.env.workspace = db1
tablelist1 = [table for table in arcpy.ListFeatureClasses()]
#['bt_riks', 'ak_riks', 'al_riks', 'an_riks', 'bs_riks']

arcpy.env.workspace = db2
tablelist2 = [table for table in arcpy.ListFeatureClasses()]
#['mb_riks', 'al_riks', 'an_riks', 'bs_riks', 'bt_riks', 'hl_riks', 'jl_riks']

commonTables = list(set(tablelist1).intersection(set(tablelist2)))
#['an_riks', 'bt_riks', 'al_riks', 'bs_riks']

resultpath = r'C:\GIS\data\tempdata'
for table in commonTables:
    t1 = os.path.join(db1, table)
    t2 = os.path.join(db2, table)
    resulttable = os.path.join(resultpath, '{0}_compared.txt'.format(table))
    arcpy.TableCompare_management(in_base_table=t1, in_test_table=t2, sort_field='OBJECTID', continue_compare='CONTINUE_COMPARE', out_compare_file=resulttable)

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.