>>> arcpy.MakeQueryLayer_management('Database Connections\my_database.sde','a_table_view','select a_field from some_table','a_field')
>>> mxd = arcpy.mapping.MapDocument("CURRENT") >>> df = mxd.activeDataFrame >>> arcpy.mapping.ListLayers(mxd,data_frame=df) [] >>> arcpy.mapping.ListTableViews(mxd,data_frame=df) [] >>>
arcpy.mapping.TableView('a_table_view')
Solved! Go to Solution.
in this line 'Database Connections\my_database.sde' you're referencing an SDE connection or a workspace.. not a table.. the arguments for the MakeQueryTable command indicate that first argument should be a reference to a table so maybe something like:
'Database Connections\my_database.sde\table_name' would work instead?
MakeQueryTable_management ( in_table, out_table, in_key_field_option, {in_key_field}, {in_field}, {where_clause})
Thanks for the reply. I'm using MakeQuery Layer_managemen
Tim,
If you go into your geoprocessing options and check the box for 'Add results of geoprocessing operations to the display' do the results get added to your map?
LOCATIONS_T = "Database Connections\\SDE DATABASE.sde\\USERNAME.LOCATION_T" arcpy.MakeQueryTable_management(LOCATION_T, "QueryTable", "USE_KEY_FIELDS", "", "", "Job_Key = " + str(Job_Key))
Tim,
I cannot reproduce this behavior on my machine, what version of ArcGIS (including service packs) are you using?
Tim,
Why are you not using the MakeQueryTable_management?LOCATIONS_T = "Database Connections\\SDE DATABASE.sde\\USERNAME.LOCATION_T" arcpy.MakeQueryTable_management(LOCATION_T, "QueryTable", "USE_KEY_FIELDS", "", "", "Job_Key = " + str(Job_Key))
This brings the queried table in to my project.