AnsweredAssumed Answered

Do I want to set the database connection as an environment in order to loop through feature classes?

Question asked by huffmanp on Dec 15, 2017
Latest reply on Dec 22, 2017 by huffmanp

After mass loading a bunch of feature classes into a enterprise geodatabases (10.3.1, MSSQL),  I need to add privileges for a role to many of them.  I tested ChangePrivileges  with a single feature class,  it worked,  so now I thought I would extend this by getting a list of feature classes, then using a For loop on the list to grant the privileges.  But it didn't wok to set up the correct database connection as a env.workspace.  What's the correct way to loop through a enterprise geodatabase to add permissions?  Or do I want to do this in a totally different way?  The following script gives a TypeError: 'NoneType' object is not iterable  on debugging line 17, indicating I didn't get anything into the list. 


# Testing how to modify enterprise geodatabase privileges with python
# Paul Huffman, 2017-12-14

import arcpy
from arcpy import env
env.workspace = "Database Connections/Streams as GisOwner.sde"

#get list of feature classes in geodatabase.
fclist = []
fclist = arcpy.ListFeatureClasses ("Database Connections/Streams as GisOwner.sde")

#datasetName = "Database Connections/Streams as GisOwner.sde/Streams.GISOWNER.str37_route_rivers"
#datasetName = "Streams.GISOWNER.str37_route_rivers"
#arcpy.ChangePrivileges_management(datasetName, "GISUsers", "GRANT", "AS_IS")

for fc in fclist:
    print fc
    #arcpy.ChangePrivileges_management(fc, "GISUsers", "GRANT", "AS_IS")