diff options
Diffstat (limited to '')
-rw-r--r-- | pgcli/explain_output_formatter.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/pgcli/explain_output_formatter.py b/pgcli/explain_output_formatter.py new file mode 100644 index 0000000..b14cf44 --- /dev/null +++ b/pgcli/explain_output_formatter.py @@ -0,0 +1,18 @@ +from pgcli.pyev import Visualizer +import json + + +"""Explain response output adapter""" + + +class ExplainOutputFormatter: + def __init__(self, max_width): + self.max_width = max_width + + def format_output(self, cur, headers, **output_kwargs): + (data,) = cur.fetchone() + explain_list = json.loads(data) + visualizer = Visualizer(self.max_width) + for explain in explain_list: + visualizer.load(explain) + yield visualizer.get_list() |