Created
October 6, 2018 16:44
-
-
Save hoehrmann/44333096afac572d404534147729c102 to your computer and use it in GitHub Desktop.
Complex table formatting of SQL Query results using JSON formatting objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- styles for CPAN module Text::ANSITable | |
SELECT | |
time, priority, message | |
, | |
json_object( | |
'priority', | |
json_object( | |
'fgcolor', | |
CASE | |
WHEN priority IN ('ERROR', 'FATAL') THEN '#ff0000' | |
WHEN priority IN ('WARN') THEN '#ffff00' | |
WHEN priority IN ('INFO') THEN NULL | |
WHEN priority IN ('DEBUG', 'TRACE') THEN '#808080' | |
ELSE NULL | |
END | |
-- , | |
-- 'bgcolor', NULL, | |
-- 'align', NULL, | |
-- 'valign', NULL, | |
-- 'formats', NULL | |
), | |
-- 'other_column', | |
-- json_object( | |
-- | |
-- ) | |
) AS __cell_style | |
, | |
json_object( | |
-- 'align', NULL, | |
-- 'valign', NULL, | |
-- 'height', NULL, | |
-- 'vpad', NULL, | |
-- 'tpad', NULL, | |
-- 'bpad', NULL, | |
-- 'fgcolor', NULL, | |
-- 'bgcolor', '#808080' | |
) AS __row_style | |
, | |
json_object( | |
'priority', | |
json_object( | |
-- 'align', NULL, | |
-- 'valign', NULL, | |
-- 'pad', NULL, | |
-- 'lpad', NULL, | |
-- 'rpad', NULL, | |
-- 'width', NULL, | |
-- 'formats', NULL, | |
-- 'fgcolor', NULL, | |
-- 'bgcolor', NULL, | |
-- 'type', NULL, | |
-- 'wrap', NULL | |
) | |
) AS __column_style | |
FROM | |
log | |
WHERE | |
priority IN ('ERROR', 'FATAL', 'WARN') | |
LIMIT 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now https://metacpan.org/pod/Text::ANSITable::SQLStyleSheet