Select to view content in your preferred language

Python/arcpy check whether a table is registered with Enterprise Geodatabase

228
1
Jump to solution
06-27-2024 11:11 AM
TylerT
by
Occasional Contributor III

Hello,

I'm looking for something like arcpy.management.is_registered(db, tbl) to determine whether a table is registered with a selected Enterprise Geodabase.  

For reference here is the method for registering a table...

arcpy.management.RegisterWithGeodatabase(<>)

 https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/register-with-geodatabase.ht...

Any ideas?


Tyler
ArcGIS Pro 3.2

0 Kudos
1 Solution

Accepted Solutions
TonyAlmeida
Occasional Contributor III

maybe something like this?

import arcpy

# Path to your table within the geodatabase
table_path = r"C:\Path\To\Your\Database.sde\TableName"

# Check if the table exists
if arcpy.Exists(table_path):
    # Get the workspace (geodatabase connection)
    workspace = arcpy.Describe(table_path).path
    
    # Check if the workspace is an Enterprise Geodatabase
    if arcpy.Describe(workspace).workspaceFactoryProgID == "esriDataSourcesGDB.SDEWorkspaceFactory.1":
        # List registered tables in the geodatabase
        registered_tables = arcpy.ListTables("*", "", workspace)
        
        # Check if the table is in the list of registered tables
        if table_path in [t.dataSource for t in registered_tables]:
            print("The table is registered with the Enterprise Geodatabase.")
        else:
            print("The table is not registered with the Enterprise Geodatabase.")
    else:
        print("The workspace is not an Enterprise Geodatabase.")
else:
    print("Table does not exist.")

 

View solution in original post

1 Reply
TonyAlmeida
Occasional Contributor III

maybe something like this?

import arcpy

# Path to your table within the geodatabase
table_path = r"C:\Path\To\Your\Database.sde\TableName"

# Check if the table exists
if arcpy.Exists(table_path):
    # Get the workspace (geodatabase connection)
    workspace = arcpy.Describe(table_path).path
    
    # Check if the workspace is an Enterprise Geodatabase
    if arcpy.Describe(workspace).workspaceFactoryProgID == "esriDataSourcesGDB.SDEWorkspaceFactory.1":
        # List registered tables in the geodatabase
        registered_tables = arcpy.ListTables("*", "", workspace)
        
        # Check if the table is in the list of registered tables
        if table_path in [t.dataSource for t in registered_tables]:
            print("The table is registered with the Enterprise Geodatabase.")
        else:
            print("The table is not registered with the Enterprise Geodatabase.")
    else:
        print("The workspace is not an Enterprise Geodatabase.")
else:
    print("Table does not exist.")