Improve console output with better formatting
Closed this issue · 0 comments
Hi,
Just needed to profile a few things in a flask app and came across your great package for profiling.
Many thanks for your hard work! I love it!
A small suggestion for output in the console.
This is the way the original console output looks like:
Repeated 2 times:
SELECT count(*) AS count_1 FROM (SELECT product.metadata AS
product_metadata, (SELECT sum(forecastsales.quantity) AS sum_1 FROM
forecastsales WHERE forecastsales.product_id = product.id AND
forecastsales.timestamp >= now() AND forecastsales.forecast_date =
(SELECT max(forecastsales.forecast_date) AS max_1 FROM
forecastsales)) AS anon_2, product.id AS product_id, product.name AS
product_name, product.default_route_id AS product_default_route_id,
product.predicted_demand_per_period AS
product_predicted_demand_per_period, product.minimum_stock_level AS
product_minimum_stock_level, product.type AS product_type FROM
product) AS anon_1
Which is hard to read.
I suggest simply using https://sqlparse.readthedocs.io/en/latest/intro/
Which when used produces this output:
Repeated 2 times:
SELECT count(*) AS count_1
FROM
(SELECT product.metadata AS product_metadata,
(SELECT sum(forecastsales.quantity) AS sum_1
FROM forecastsales
WHERE forecastsales.product_id = product.id
AND forecastsales.timestamp >= now()
AND forecastsales.forecast_date =
(SELECT max(forecastsales.forecast_date) AS max_1
FROM forecastsales)) AS anon_2,
product.id AS product_id,
product.name AS product_name,
product.default_route_id AS product_default_route_id,
product.predicted_demand_per_period AS product_predicted_demand_per_period,
product.minimum_stock_level AS product_minimum_stock_level,
product.type AS product_type
FROM product) AS anon_1
All colors (green, yellow, red) are still marked as they were (cannot show them here, but no functionality of your code changes, just the string input/output is better formatted.)
I will make a PR with this change (it's just 2 lines of code + requirements.txt) and let me know what you think.
Again - many thx for this tool - it's a godsend :)
Take care,
Tomasz