Currently, I can format my SQL queries programmatically by making POST
request to the API; but there is a limitation of 500 request can be served per hour from the single IP as mentioned here .
I am wondering if there is a local Javascript
or other mechanism available in by which I can achieve the same result as obtained from the SQLFormat website locally without going to the web?
Currently, I can format my SQL queries programmatically by making POST
request to the http://sqlformat/api/v1/format API; but there is a limitation of 500 request can be served per hour from the single IP as mentioned here http://sqlformat/api/#usage.
I am wondering if there is a local Javascript
or other mechanism available in by which I can achieve the same result as obtained from the SQLFormat website locally without going to the web?
2 Answers
Reset to default 3There is a javascript library to do that https://github./zeroturnaround/sql-formatter
Usage:
import sqlFormatter from "sql-formatter";
console.log(sqlFormatter.format("SELECT * FROM table1"));
This will output:
SELECT
*
FROM
table1
You can use sql-formater from npm:
npm install sql-formatter
then
import { format } from 'sql-formatter';
console.log(format('SELECT * FROM tbl', { language: 'mysql' }));