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

uroboro​SQL Formatter

Beautiful SQL Formatter for Sublime Text 3

Details

Installs

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

Readme

Source
raw.​githubusercontent.​com

uroboroSQL Formatter

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 -- メーカーコード
,
       MI.BRAND_CD AS ITEM_BRAND_CD -- ブランドコード
,
       MI.ITEM_CD AS ITEM_CD -- 商品コード
,
       MI.CATEGORY AS ITEM_CATEGORY -- 商品カテゴリ
FROM M_ITEM MI -- 商品マスタ

WHERE 1 = 1
  AND MI.ARRIVAL_DATE = '2016-12-01' -- 入荷日

In case of uroboroSQL Formatter

SELECT
    MI.MAKER_CD AS  ITEM_MAKER_CD   -- メーカーコード
,   MI.BRAND_CD AS  ITEM_BRAND_CD   -- ブランドコード
,   MI.ITEM_CD  AS  ITEM_CD         -- 商品コード
,   MI.CATEGORY AS  ITEM_CATEGORY   -- 商品カテゴリ
FROM
    M_ITEM  MI  -- 商品マスタ
WHERE
    1               =   1
AND MI.ARRIVAL_DATE =   '2016-12-01'    -- 入荷日

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_uppercase": true,
    "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_uppercase
    • If you want to convert a reserved word and identifier to uppercase specifies true.
  • 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 2017 by Future Architect.