Edit a Query Layer with Arcpy

Unfortunately, there is no way to edit the query table after it was created in ArcMap using arcpy. You will need to use ArcObjects either using .NET/Java/C++ or using comtypes in Python to work the COM interfaces.

You have a couple of options:

  1. Use a regular feature layer and set its definition query using Layer object using arcpy.

  2. Create a database view using SQL tools or ArcGIS Create Database View GP tool and then modify its definition as needed.