Skip to content

For Internal Use

License

Notifications You must be signed in to change notification settings

LincWorld/js-sql-parser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

js-sql-parser

parse / stringify sql like grammer in js.

NPM

commonjs usage

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 tag

<script src="./dist/parser/sqlParser.js"><script/>

var sqlParser = window.sqlParser;
var ast = sqlParser.parse('get * from dual');
var sql = sqlParser.stringify(ast);

Build

  • Run npm run build to build the distributable.

LICENSE

MIT