ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

uroboro​SQL Formatter

by future-architect ST3 Missing

Beautiful SQL Formatter for Sublime Text 3

Details

Installs

  • Total 15K
  • Win 8K
  • Mac 5K
  • Linux 2K
Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6 Mar 5 Mar 4 Mar 3 Mar 2 Mar 1 Feb 28 Feb 27 Feb 26 Feb 25 Feb 24 Feb 23 Feb 22 Feb 21 Feb 20 Feb 19 Feb 18 Feb 17 Feb 16 Feb 15 Feb 14 Feb 13 Feb 12
Windows 0 3 1 4 4 3 0 0 1 1 1 3 4 0 0 1 2 1 1 1 0 0 2 4 3 4 1 0 0 0 2 1 0 2 0 1 1 2 1 4 0 0 0 2 0 2
Mac 0 1 2 2 3 1 0 1 1 1 0 0 0 0 0 2 2 0 2 4 0 0 3 2 2 1 1 1 0 1 2 0 2 0 0 0 0 3 0 2 0 0 0 0 2 0
Linux 0 0 0 0 0 0 0 0 0 1 0 1 1 0 1 0 1 1 0 2 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 0 0 0
0246Mar 29Mar 26Mar 23Mar 20Mar 17Mar 14Mar 11Mar 8Mar 5Mar 2Feb 27Feb 24Feb 21Feb 18Feb 15Feb 12Mar 29 Linux: 0 Mac: 0 Windows: 0Mar 28 Linux: 0 Mac: 1 Windows: 3Mar 27 Linux: 0 Mac: 2 Windows: 1Mar 26 Linux: 0 Mac: 2 Windows: 4Mar 25 Linux: 0 Mac: 3 Windows: 4Mar 24 Linux: 0 Mac: 1 Windows: 3Mar 23 Linux: 0 Mac: 0 Windows: 0Mar 22 Linux: 0 Mac: 1 Windows: 0Mar 21 Linux: 0 Mac: 1 Windows: 1Mar 20 Linux: 1 Mac: 1 Windows: 1Mar 19 Linux: 0 Mac: 0 Windows: 1Mar 18 Linux: 1 Mac: 0 Windows: 3Mar 17 Linux: 1 Mac: 0 Windows: 4Mar 16 Linux: 0 Mac: 0 Windows: 0Mar 15 Linux: 1 Mac: 0 Windows: 0Mar 14 Linux: 0 Mac: 2 Windows: 1Mar 13 Linux: 1 Mac: 2 Windows: 2Mar 12 Linux: 1 Mac: 0 Windows: 1Mar 11 Linux: 0 Mac: 2 Windows: 1Mar 10 Linux: 2 Mac: 4 Windows: 1Mar 9 Linux: 0 Mac: 0 Windows: 0Mar 8 Linux: 0 Mac: 0 Windows: 0Mar 7 Linux: 0 Mac: 3 Windows: 2Mar 6 Linux: 1 Mac: 2 Windows: 4Mar 5 Linux: 0 Mac: 2 Windows: 3Mar 4 Linux: 0 Mac: 1 Windows: 4Mar 3 Linux: 0 Mac: 1 Windows: 1Mar 2 Linux: 0 Mac: 1 Windows: 0Mar 1 Linux: 0 Mac: 0 Windows: 0Feb 28 Linux: 0 Mac: 1 Windows: 0Feb 27 Linux: 0 Mac: 2 Windows: 2Feb 26 Linux: 0 Mac: 0 Windows: 1Feb 25 Linux: 0 Mac: 2 Windows: 0Feb 24 Linux: 0 Mac: 0 Windows: 2Feb 23 Linux: 0 Mac: 0 Windows: 0Feb 22 Linux: 0 Mac: 0 Windows: 1Feb 21 Linux: 1 Mac: 0 Windows: 1Feb 20 Linux: 0 Mac: 3 Windows: 2Feb 19 Linux: 0 Mac: 0 Windows: 1Feb 18 Linux: 0 Mac: 2 Windows: 4Feb 17 Linux: 0 Mac: 0 Windows: 0Feb 16 Linux: 1 Mac: 0 Windows: 0Feb 15 Linux: 1 Mac: 0 Windows: 0Feb 14 Linux: 0 Mac: 0 Windows: 2Feb 13 Linux: 0 Mac: 2 Windows: 0Feb 12 Linux: 0 Mac: 0 Windows: 2Mar 29 Linux: 0 Mac: 0 Windows: 0Mar 28 Linux: 0 Mac: 1 Windows: 3Mar 27 Linux: 0 Mac: 2 Windows: 1Mar 26 Linux: 0 Mac: 2 Windows: 4Mar 25 Linux: 0 Mac: 3 Windows: 4Mar 24 Linux: 0 Mac: 1 Windows: 3Mar 23 Linux: 0 Mac: 0 Windows: 0Mar 22 Linux: 0 Mac: 1 Windows: 0Mar 21 Linux: 0 Mac: 1 Windows: 1Mar 20 Linux: 1 Mac: 1 Windows: 1Mar 19 Linux: 0 Mac: 0 Windows: 1Mar 18 Linux: 1 Mac: 0 Windows: 3Mar 17 Linux: 1 Mac: 0 Windows: 4Mar 16 Linux: 0 Mac: 0 Windows: 0Mar 15 Linux: 1 Mac: 0 Windows: 0Mar 14 Linux: 0 Mac: 2 Windows: 1Mar 13 Linux: 1 Mac: 2 Windows: 2Mar 12 Linux: 1 Mac: 0 Windows: 1Mar 11 Linux: 0 Mac: 2 Windows: 1Mar 10 Linux: 2 Mac: 4 Windows: 1Mar 9 Linux: 0 Mac: 0 Windows: 0Mar 8 Linux: 0 Mac: 0 Windows: 0Mar 7 Linux: 0 Mac: 3 Windows: 2Mar 6 Linux: 1 Mac: 2 Windows: 4Mar 5 Linux: 0 Mac: 2 Windows: 3Mar 4 Linux: 0 Mac: 1 Windows: 4Mar 3 Linux: 0 Mac: 1 Windows: 1Mar 2 Linux: 0 Mac: 1 Windows: 0Mar 1 Linux: 0 Mac: 0 Windows: 0Feb 28 Linux: 0 Mac: 1 Windows: 0Feb 27 Linux: 0 Mac: 2 Windows: 2Feb 26 Linux: 0 Mac: 0 Windows: 1Feb 25 Linux: 0 Mac: 2 Windows: 0Feb 24 Linux: 0 Mac: 0 Windows: 2Feb 23 Linux: 0 Mac: 0 Windows: 0Feb 22 Linux: 0 Mac: 0 Windows: 1Feb 21 Linux: 1 Mac: 0 Windows: 1Feb 20 Linux: 0 Mac: 3 Windows: 2Feb 19 Linux: 0 Mac: 0 Windows: 1Feb 18 Linux: 0 Mac: 2 Windows: 4Feb 17 Linux: 0 Mac: 0 Windows: 0Feb 16 Linux: 1 Mac: 0 Windows: 0Feb 15 Linux: 1 Mac: 0 Windows: 0Feb 14 Linux: 0 Mac: 0 Windows: 2Feb 13 Linux: 0 Mac: 2 Windows: 0Feb 12 Linux: 0 Mac: 0 Windows: 2Mar 29 Linux: 0 Mac: 0 Windows: 0Mar 28 Linux: 0 Mac: 1 Windows: 3Mar 27 Linux: 0 Mac: 2 Windows: 1Mar 26 Linux: 0 Mac: 2 Windows: 4Mar 25 Linux: 0 Mac: 3 Windows: 4Mar 24 Linux: 0 Mac: 1 Windows: 3Mar 23 Linux: 0 Mac: 0 Windows: 0Mar 22 Linux: 0 Mac: 1 Windows: 0Mar 21 Linux: 0 Mac: 1 Windows: 1Mar 20 Linux: 1 Mac: 1 Windows: 1Mar 19 Linux: 0 Mac: 0 Windows: 1Mar 18 Linux: 1 Mac: 0 Windows: 3Mar 17 Linux: 1 Mac: 0 Windows: 4Mar 16 Linux: 0 Mac: 0 Windows: 0Mar 15 Linux: 1 Mac: 0 Windows: 0Mar 14 Linux: 0 Mac: 2 Windows: 1Mar 13 Linux: 1 Mac: 2 Windows: 2Mar 12 Linux: 1 Mac: 0 Windows: 1Mar 11 Linux: 0 Mac: 2 Windows: 1Mar 10 Linux: 2 Mac: 4 Windows: 1Mar 9 Linux: 0 Mac: 0 Windows: 0Mar 8 Linux: 0 Mac: 0 Windows: 0Mar 7 Linux: 0 Mac: 3 Windows: 2Mar 6 Linux: 1 Mac: 2 Windows: 4Mar 5 Linux: 0 Mac: 2 Windows: 3Mar 4 Linux: 0 Mac: 1 Windows: 4Mar 3 Linux: 0 Mac: 1 Windows: 1Mar 2 Linux: 0 Mac: 1 Windows: 0Mar 1 Linux: 0 Mac: 0 Windows: 0Feb 28 Linux: 0 Mac: 1 Windows: 0Feb 27 Linux: 0 Mac: 2 Windows: 2Feb 26 Linux: 0 Mac: 0 Windows: 1Feb 25 Linux: 0 Mac: 2 Windows: 0Feb 24 Linux: 0 Mac: 0 Windows: 2Feb 23 Linux: 0 Mac: 0 Windows: 0Feb 22 Linux: 0 Mac: 0 Windows: 1Feb 21 Linux: 1 Mac: 0 Windows: 1Feb 20 Linux: 0 Mac: 3 Windows: 2Feb 19 Linux: 0 Mac: 0 Windows: 1Feb 18 Linux: 0 Mac: 2 Windows: 4Feb 17 Linux: 0 Mac: 0 Windows: 0Feb 16 Linux: 1 Mac: 0 Windows: 0Feb 15 Linux: 1 Mac: 0 Windows: 0Feb 14 Linux: 0 Mac: 0 Windows: 2Feb 13 Linux: 0 Mac: 2 Windows: 0Feb 12 Linux: 0 Mac: 0 Windows: 2

Readme

Source
raw.​githubusercontent.​com

Sublime uroboroSQL Formatter

Package Control

Sublime uroboroSQL Formatter is often used in enterprise systems, For formatting to a highly maintainable style even for very long SQL (1 K step or more) It is a plug-in of Sublime Text 3.

In particular, in countries where English is not their mother tongue, such as Japan, comments may be included in SELECT clauses. In that case, we will align the vertical position of the AS clause and the comment, pursuing the viewability which can be said as artistic anymore, This was developed to realize this automatically.

for Japanese, Readme.ja.md

In case of general formatter

SELECT MI.MAKER_CD AS ITEM_MAKER_CD -- maker code
,
       MI.BRAND_CD AS ITEM_BRAND_CD -- brand code
,
       MI.ITEM_CD AS ITEM_CD -- item code
,
       MI.CATEGORY AS ITEM_CATEGORY -- item category
FROM M_ITEM MI -- item master

WHERE 1 = 1
  AND MI.ARRIVAL_DATE = '2016-12-01' -- arrival date

In case of Sublime uroboroSQL Formatter

SELECT
    MI.MAKER_CD AS  ITEM_MAKER_CD   -- maker code
,   MI.BRAND_CD AS  ITEM_BRAND_CD   -- brand code
,   MI.ITEM_CD  AS  ITEM_CD         -- item code
,   MI.CATEGORY AS  ITEM_CATEGORY   -- item category
FROM
    M_ITEM  MI  -- item master
WHERE
    1               =   1
AND MI.ARRIVAL_DATE =   '2016-12-01'    -- arrival date

Features

  • Formatting by aligning the vertical position of AS and operator in SELECT clause, WHERE clause
  • Even if there is a comment at the end of each line, the format

How to Use

  • Select “SQL Format” from the Edit menu
  • Select “SQL Format” from the context menu on the editor
  • Select “uroboroSQL Formatter: Format SQL” from the command Palette
  • ctrl + cmd + f on OS X, or ctrl + alt + f on Windows

Settings

{
    "uf_tab_size": 4,
    "uf_translate_tabs_to_spaces": true,
    "uf_case": "upper", // "upper" or "lower" or "capitalize" or "nochange"
    "uf_reserved_case": "upper", // "upper" or "lower" or "capitalize" or "nochange"
    "uf_reserved_words":"SELECT, FROM, WHERE, CREATE", // Put commas to separate reserved words
    "uf_comment_syntax": "uroboroSQL", // "uroboroSQL" or "doma2"
    "uf_escapesequence_u005c": false,
    "uf_save_on_format": true,
    "uf_save_on_format_extensions": [".sql"]
}
  • uf_tab_size
    • Specify the tab size of the indent after formatting. We recommend 4.
  • uf_translate_tabs_to_spaces
    • Specify whether the indent after formatting is tab or space. It becomes a space by setting it to true.
  • uf_case
    • If you want to convert all words to a specific case, set “upper”, “lower”, “capitalize”. If the “nochange” option is selected, the word cases will not be changed from the original.
  • uf_reserved_case
    • If you want to convert reserved words to a specific case, set “upper”, “lower” or “capitalize”. If the “nochange” option is selected, it will not change the cases of resered words and they will be changed based on the “uf_case” setting.
  • uf_reserved_words
    • If you want to convert only reserved words to a specific case, please input reserved words sepalated by a comma. (The input is not case sensitive. So you can input reserved words in any case.)
  • uf_comment_syntax
    • It specifies the comment syntax format.
    • You can specify the “uroboroSQL” or “doma2”.
      • In the case of normal SQL, you can specify either.
  • uf_escapesequence_u005c
    • If you have specified the escape sequence with a backslash in the SQL to specify the true.
  • uf_save_on_format
    • Specify true when formatting automatically when saving files.
  • uf_save_on_format_extensions
    • Specify the extension of the file to be formatted in a list.

License

python-sqlparse library and this code are both on 2-clauses BSD


Copyright 2018 by Future Architect.