Was expecting something like DESCRIBE but for less technical audience. As a heavy SQL user, I don't see much benefit in this as of yet. It is very misleading in saying it is the "most human readable" format, when the example shows the "format" to be identical to the original. Just by upper-casing keywords doesn't make it any more readable to be honest. Anyways a good attempt, hope you're not offended by critical feed…
Show HN: Readsql – convert SQL to most human readable format
21–30 of 32 posts
Re: Show HN: Readsql – convert SQL to most human readable format
#22Earlier quoted context omitted.
I understand the wonder, this is not some kind of magic that will help us solve all SQL issues. That's way too hard. This is a development tool that helps write and read SQL code. So simply saves development time by automating the easy stuff, leaving the hard and important stuff for us to deal with. It is different from other formatters that it lints code inside Python strings. For some context, I am a data engineer…
Ok that puts it in context a little bit, if it’s making your life easier then it must be useful to people in the same position and role. I’ve o it ever written SQL in stored procs and one off queries so relied on Redgates SQL Prompt tool (you might want to take a look at what that does for some inspiration)
Re: Show HN: Readsql – convert SQL to most human readable format
#23Does it do anything but uppercase keywords? Is it going to add line breaks or indentation at some point?
Adding line breaks before FROM, JOIN, WHERE, GROUP BY, ORDER BY, LIMIT/OFFSET (and usually before some of the ANDs) is the first thing I do when analyzing some SQL. Capitalization is rarely needed after that and useful for longer term readability. I also normalize by removing optional/redundant keyword noise, I'm looking at you INNER/OUTER.
Re: Show HN: Readsql – convert SQL to most human readable format
#24Was expecting something like DESCRIBE but for less technical audience. As a heavy SQL user, I don't see much benefit in this as of yet. It is very misleading in saying it is the "most human readable" format, when the example shows the "format" to be identical to the original. Just by upper-casing keywords doesn't make it any more readable to be honest. Anyways a good attempt, hope you're not offended by critical feed…
Thank you for the feedback. The example in Github has code highlighting. I wonder if I should remove that and if that would make more difference. I would be interested to know how this tool could help you with your SQL usage
A difficult but incredibly useful idea would be to learn the developer’s style and then format code (theirs or others’) to fit that model.
Re: Show HN: Readsql – convert SQL to most human readable format
#25Leaving aside the modest achievements of the code so far, the missing prerequisite to "automatically" formatting SQL is... just formatting SQL. Because SQL (broadly) was designed to be "human" readable in the first place, it's grammatically very inconsistent and with a lot of keywords. Much more than other languages in use today such as C. I've yet to find a pattern of indentation, brackets etc. that satisfies my OCD…
I tend to classify SQL statements into two kinds, those that when wrapped in a calling function fit in one screen, and those other longer ones that I'm inclined to write in an imperative language.
Edit: For the author of the repository, the list of reserved words gets longer and more complex when you support different implementations of SQL, and regex may be insufficient once you consider such parsing questions as whether the keyword is within quotation marks or part of a user-defined name.
https://www.drupal.org/docs/develop/coding-standards/list-of...
https://github.com/AzisK/readsql/blob/master/readsql/regexes...
Re: Show HN: Readsql – convert SQL to most human readable format
#26Leaving aside the modest achievements of the code so far, the missing prerequisite to "automatically" formatting SQL is... just formatting SQL. Because SQL (broadly) was designed to be "human" readable in the first place, it's grammatically very inconsistent and with a lot of keywords. Much more than other languages in use today such as C. I've yet to find a pattern of indentation, brackets etc. that satisfies my OCD…
I make an effort to indent on most keywords, using a Python-like structure to indent related lines to the same level, one more than the keyword operating on them all, with the heuristic that if I can comment one or more lines to debug, I have a readable query. I tend to classify SQL statements into two kinds, those that when wrapped in a calling function fit in one screen, and those other longer ones that I'm incline…
Re: Show HN: Readsql – convert SQL to most human readable format
#27Earlier quoted context omitted.
For now it only upper-cases but I would like it to "prettify" the code as well. So it is an upcoming feature. Hopefully it will even suggest SQL code improvements in the future. Contributions are welcome
I don't really get it. Is upper case more human readable than lower case?
In any case, it is objectively not more human writeable.