Applying dynamic filters to a SQL query using Python conditional expressions
The code in the post seems fine. I think it would be easier to read if you kept the lines to 79 columns or less, put each conditional in its own statement, and made the field names match the query parameter names, like this:

query = """
    SELECT AVG(stock_date - order_date) AS c, product_category
    FROM data_table_data
    WHERE stock_date BETWEEN :stock_date_start AND :stock_date_end
"""
if category != 'All Category':
    query += "AND product_category = :product_category "
if store_location != 'All Stores':
    query += "AND product_location = :product_location "
query += "GROUP BY product_category"
params = dict(stock_date_start=startDate,
              stock_date_end=endDate,
              product_category=category,
              product_location=store_location)
data = engine.execute(text(query), **params).fetchall()


Alternatively, you could push the conditional down into the SQL, and then the query would be constant:

QUERY = """
    SELECT AVG(stock_date - order_date) AS c, product_category
    FROM data_table_data
    WHERE stock_date BETWEEN :s1 AND :s2
    AND product_category IN ('All Category', :product_category)
    AND product_location IN ('All Stores', :product_location)
    GROUP BY product_category
"""