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'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On my box it's a dir