Last active
December 12, 2022 02:13
-
-
Save chrismo/ff00f2e6409b22e73ef7 to your computer and use it in GitHub Desktop.
Sequel Pro Format Sql Bundle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruby formatsql.rb "$(cat)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put this in ~/Library/Application Support/Sequel Pro/Bundles/Format SQL.spBundle | |
require 'net/http' | |
require 'json' | |
uri = URI('http://www.gudusoft.com/format.php') | |
opts = {"capitalization"=>{"keywords"=>{"fmt100_case_keyword"=>"lower"}, "tableName"=>{"fmt105_case_table_name"=>"lower"}}} | |
# API details: https://github.com/sqlparser/sql-pretty-printer/wiki/SQL-FaaS-API-manual | |
res = Net::HTTP.post_form(uri, 'rqst_input_sql' => ARGV[0], 'rspn_db_vendor' => 'mysql', 'rqst_formatOptions' => opts.to_json) | |
puts JSON.parse(res.body)['rspn_formatted_sql'] | |
and where does the formatsql.rb file live?
Ah, I put that in the original location of the bundle files, which is ... ~/Library/Application Support/Sequel Pro/Bundles/Format SQL.spBundle
In the Bundles folder, right? That .spBundle file is a file.
On my box it's a dir
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The 'bundle editor.sh' file is the contents to put into the Command text box of the Bundle Editor. It removes the code that warns this data is being sent in the clear over the internets, so if you still care about that you'll have to dig that out of the original shell Command. here
The gudusoft.com is the current endpoint for the prior dpriver.com functionality.