core

format_where

assert_and_print(
    format_where(
        "WHERE brand = 'my_brand'"
    ), "WHERE  brand = 'my_brand'"
)
WHERE  brand = 'my_brand'

format_sql

assert_and_print(
    format_sql("SELECT brand FROM table WHERE brand = 'my_brand'"),
"""
SELECT brand
FROM   table
WHERE  brand = 'my_brand'
""".strip()
)
SELECT brand
FROM   table
WHERE  brand = 'my_brand'
assert_and_print(
    format_sql(
"""SELECT var 
    FROM table_selection as a 
    LEFT JOIN table2 as b ON a.id = b.id 
    LEFT JOIN table3 as c ON a.id = c.id 
    ORDER BY 1
"""),
"""
SELECT var
FROM   table_selection as a
    LEFT JOIN table2 as b
        ON a.id = b.id
    LEFT JOIN table3 as c
        ON a.id = c.id
ORDER BY 1
""".strip()
)
SELECT var
FROM   table_selection as a
    LEFT JOIN table2 as b
        ON a.id = b.id
    LEFT JOIN table3 as c
        ON a.id = c.id
ORDER BY 1

utils

split_query

assert_and_print(
    split_query("select var from table_selection"),
    [{"string": "select var ", "comment": False, "quote": False, "select": True}, 
     {"string": "from table_selection", "comment": False, "quote": False, "select": False}]
)
[{'string': 'select var ', 'comment': False, 'quote': False, 'select': True}, {'string': 'from table_selection', 'comment': False, 'quote': False, 'select': False}]