I have an SQL Server view that at I want to include in my ArcGIS server's REST endpoint as a table. I'm able to do it manually using ArcMap - it appears to create a query table when I drag the view onto the table of contents. How can I do this in python?
Currently I go through this sequence
- Start with a blank mxd file: mxd_template_obj = arcpy.mapping.MapDocument(blank_template_fn)
- Get the dataframe: df = ListDataFrames(mxd_template_obj)
- Create the query table (according to the documentation is creates a TableView): arcpy.MakeQueryTable_management(db_view, table_view_name, ....)
- Convert it to a TableView object: table_view = arcpy.mapping.TableView(table_view_name)
- Add it to the map: arcpy.mapping.AddTableView(df, table_view)
- Save the map: mxd_template_obj.saveACopy(<mxd_file_name>)
It appears to generate a good mxd file - I can go into ArcMap and everything looks correct, but when I try to stage it for publishing I get this error:
ExecuteError: ERROR 001272: Analyzer errors were encountered (codes = 33, 33)
Standalone table's data source is not supported
I suspect that my step 4 is wrong - once I have the query table I need to do something else to get it into the map correctly but I'm not sure what that is.