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

uroboro​SQL Formatter

Beautiful SQL Formatter for Sublime Text 3

Details

Installs

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

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.