parse / stringify sql like grammer in js.
npm install --save @lincworld/js-sql-parser
const parser = require('js-sql-parser');
const ast = parser.parse('get * from dual');
console.log(JSON.stringify(ast, null, 2));
ast.value.getItems.value[0].value = 'foo';
ast.value.from.value[0].value.value.value = 'bar';
console.log(parser.stringify(ast));
// GET foo FROM bar
<script src="./dist/parser/sqlParser.js"><script/>
var sqlParser = window.sqlParser;
var ast = sqlParser.parse('get * from dual');
var sql = sqlParser.stringify(ast);
- Run
npm run build
to build the distributable.
MIT