4 ms·
Any recommendation for a prettifier / SQL linter?
by emmanuel_1234 2y ago
Any recommendation for a prettifier / SQL linter?
- gnulinux 2y agoI'm curious about this for DuckDB [1]. In the last couple months or so I've been using DuckDB as a one-step solution to all problems I solve. In fact my development environment rarely requires anything other than Python and DuckDB (and some Rust if native code is necessary). DuckDB is an insanely fast and featureful analytic db. It'd be nice to have a linter, formatter etc specifically for DuckDB. There is sqlfluff etc but I'm curious what people use. [1] DuckDB SQL dialect is very close to Postgres, it's compatible in many ways but has some extra QOL features related to analytics, and lacks a few features like `vacuum full`;
- ptman 2y agosqlfluff is better than https://github.com/darold/pgFormatter https://github.com/darold/pgFormatter , but it can get confused at times.
- chrisjc 2y agoSince you're using python, have you looked into sqlglot? I think it has some pretty-print options. https://github.com/tobymao/sqlglot https://github.com/tobymao/sqlglot
- deleted 2y ago[deleted]
- homebrewer 2y agoIDEA if you want to use it for other things (or any other JetBrains IDE). Nothing comes close feature-wise. If you don't: - https://www.depesz.com/2022/09/21/prettify-sql-queries-from-command-line/#more-4112 https://www.depesz.com/2022/09/21/prettify-sql-queries-from-... - https://gitlab.com/depesz/pg-sql-prettyprinter https://gitlab.com/depesz/pg-sql-prettyprinter Or https://paste.depesz.com https://paste.depesz.com for one-off use.
- jillyboel 2y agoi think the idea sql prettifier is pretty silly sometimes. it really likes indenting stuff to make sure things are aligned, which often results in dozens of whitespaces
- homebrewer 2y agoIt makes it easy to distinguish null vs not null columns and other similar things, so I personally don't mind.
- jillyboel 2y agoIt's more about queries like (dummy example) RETURN CASE WHEN a = 1 THEN 1 ELSE 2 END; where it insists on aligning WHEN past CASE. I think it would be perfectly reasonable to indent WHEN and ELSE 4 spaces less, for example. Similar things happen with nested conditions like (a or (b and c)) all getting pushed to the right
- NegativeLatency 2y agoprettier plugin sql, or pg_format
- mustime 2y ago[dead]