最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Local JavaScript Function to Format SQL queries like SQLFormat.org performs without the web call? - Stack Overflow

programmeradmin4浏览0评论

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?

Share Improve this question edited Mar 17, 2016 at 17:16 CRSouser 6789 silver badges26 bronze badges asked Oct 16, 2014 at 7:34 user850234user850234 3,46315 gold badges52 silver badges84 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

There 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' }));

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论