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

646
2
08-28-2018 12:03 AM
BenVan_Kesteren1
Occasional Contributor III

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

2 Replies
Madanbhurati
New Contributor III

Hi Ben, Thanks for the post. these two propserties (isVersioned & editorTrakingEnabled) are usefull for my script.

0 Kudos
BenVan_Kesteren1
Occasional Contributor III

Hey, I found someone elses post on here that listed dozens of objects that arcpy can use, it can be found here - https://community.esri.com/thread/197110-how-to-introspect-a-describe-object#comment-696327 

It is a very useful post too!

0 Kudos