Hey all,
I am attempting to create a script that rebuilds indexes and updates statistics on tables on a regular schedule. I am using an Oracle enterprise geodatabase.
I am using this post from Esri to try and recreate my script (see the Rebuild indexes and update statistics section): Using Python scripting to batch reconcile and post traditional versions
When I try and run my code (below), I get this error which is noting the dataList variable as the problem:
TypeError: unsupported operand type(s) for +: 'NoneType' and 'NoneType'
workspace = r"A:\File\Path\dataowner.sde"
userName = arcpy.Describe(workspace).connectionProperties.user
dataList = arcpy.ListTables(userName + '.*') + arcpy.ListFeatureClasses(userName + '.*') + arcpy.ListRasters(userName + '.*')
for dataset in arcpy.ListDatasets(userName + '.*'):
dataList += arcpy.ListFeatureClasses(feature_dataset=dataset)
arcpy.RebuildIndexes_management(workspace, "NO_SYSTEM", dataList, "ALL")
arcpy.AnalyzeDatasets_management(workspace, "NO_SYSTEM", dataList, "ANALYZE_BASE", "ANALYZE_DELTA", "ANALYZE_ARCHIVE")
Thanks - Josh
Solved! Go to Solution.
The error is because the result of ListTables is empty/null. Try setting the environment workspace as shown on the first line of the example in the docs.
# set the workspace
arcpy.env.workspace = r"A:\File\Path\dataowner.sde"
# Set a variable for the workspace
workspace = arcpy.env.workspace
userName = arcpy.Describe(workspace).connectionProperties.user
dataList = arcpy.ListTables(userName + '.*') + arcpy.ListFeatureClasses(userName + '.*') + arcpy.ListRasters(userName + '.*')
for dataset in arcpy.ListDatasets(userName + '.*'):
dataList += arcpy.ListFeatureClasses(feature_dataset=dataset)
arcpy.RebuildIndexes_management(workspace, "NO_SYSTEM", dataList, "ALL")
arcpy.AnalyzeDatasets_management(workspace, "NO_SYSTEM", dataList, "ANALYZE_BASE", "ANALYZE_DELTA", "ANALYZE_ARCHIVE")
The error is because the result of ListTables is empty/null. Try setting the environment workspace as shown on the first line of the example in the docs.
# set the workspace
arcpy.env.workspace = r"A:\File\Path\dataowner.sde"
# Set a variable for the workspace
workspace = arcpy.env.workspace
userName = arcpy.Describe(workspace).connectionProperties.user
dataList = arcpy.ListTables(userName + '.*') + arcpy.ListFeatureClasses(userName + '.*') + arcpy.ListRasters(userName + '.*')
for dataset in arcpy.ListDatasets(userName + '.*'):
dataList += arcpy.ListFeatureClasses(feature_dataset=dataset)
arcpy.RebuildIndexes_management(workspace, "NO_SYSTEM", dataList, "ALL")
arcpy.AnalyzeDatasets_management(workspace, "NO_SYSTEM", dataList, "ANALYZE_BASE", "ANALYZE_DELTA", "ANALYZE_ARCHIVE")
I completely overlooked that. Thanks @BlakeTerhune!