ben_vk

Finding Feature Classes (FC) in Enterprise SDE that are Versioned, and finding FC's that have Editor Tracking enabled

Discussion created by ben_vk on Aug 28, 2018
Latest reply on Aug 28, 2018 by ben_vk

The purpose of this post is to help future me find these tools again, and hopefully if someone else out there in ESRI land is trying to find either of these two specific cases, you find this useful in your own situation.

 

This is a very easy way for myself to list all tables within my enterprise SDE that are currently registered as versioned, its only a couple of lines of code, and I thought if someone is googling this that it may be able to help them:

 

import arcpy
arcpy.env.workspace = r'Database Connections\GISADMIN@SDE_Spatial@SDE-DB.sde'
ds=arcpy.ListDatasets()
for d in ds:
  for fc in arcpy.ListFeatureClasses(feature_dataset=d):
    print '{}:alias={}'.format(fc,arcpy.Describe(fc).aliasName)
    if arcpy.Describe(fc).isVersioned:
      print(fc)

Note: in these examples you will notice that I am listing all datasets, and then iterating over these, and passing the dataset into the ListFeatureClasses tool, this is because the ListFeatureClasses tool crashes in my environment, if I do not pass in a feature class. Its not the most efficient piece of code, but it doesn't crash.

 

And this second piece of code iterates over the Database, and returns all Feature Classes that are yet to have editor tracking enabled on them, another item that may help a fellow ESRI user out:

import arcpy
arcpy.env.workspace = r'Database Connections\GISADMIN@SDE_Spatial@SDE-DB.sde'
ds=arcpy.ListDatasets()
for d in ds:
  for fc in arcpy.ListFeatureClasses(feature_dataset=d):
    if not arcpy.Describe(fc).editorTrackingEnabled:
      print(fc)

 

Here is a bonus piece of code I find handy, it returns a print out of all "Datasets"|"FeatureClasses"|"Alias"

import arcpy
arcpy.env.workspace = r'Database Connections\GISADMIN@SDE_Spatial@SDE-DB.sde'
ds=arcpy.ListDatasets()
for d in ds:
for fc in arcpy.ListFeatureClasses(feature_dataset=d):
print("{}|{}|{}").format(d,fc,arcpy.Describe(fc).aliasName)

 

Cheers

Outcomes