Better HN
topnewbestaskshowjobs
Log inSign up

the_ez

12 karma · joined Nov 3, 2016 (10y ago) · 1 submissions

Submissions

comment 10y ago · link · parent

sqlparse comes to mind - https://github.com/andialbrecht/sqlparse

I know the maintainer, they also run a service at https://sqlformat.org/

You can try it on the command line e.g. on Fedora:

  $ sudo dnf install python3-sqlparse
  $ echo "select c1, c2, c3 from table1 join table2 t2 on t1.col2 = t2.col1 where 1=2 order by col2 limit 100" | sqlformat -k upper -i lower -sa -
  SELECT c1,
         c2,
         c3
    FROM table1
    JOIN table2 t2
      ON t1.col2 = t2.col1
   WHERE 1 = 2
   ORDER BY col2
   LIMIT 100