format-sql.de

Makes your SQL readable.



SELECT
    SUM(t1.*) AS sum1
FROM
    table1 AS t1
    LEFT JOIN table2 t2 ON
        t1.id = t2.id
WHERE
    t1.x = 1
    AND t1.id <> t2.id;

API

You can use format-sql via an API. The expeceted input is a JSON dictionary with the statement as entry. POST the request to http://format-sql.de/api.

Here is an example in Python.

1
2
3
4
5
>>> import requests
>>> data = {'statement': 'select * from x'}
>>> resp = requests.post('http://format-sql.de/api', data)
>>> resp.json()
{'statement': 'SELECT\n    *\nFROM\n    x', 'success': True}

The call returns a JSON dictionary with 2 entries: statement and success. success can be true or false and indicates if your input could be handled properly.

In case success is true, statement holds the formatted SQL. If success is false, an additional entry error_message is provided to help find out what went wrong.

If you experience any errors please send me a message. You can also help develop format-sql on GitHub.