1.0.16 • Published 5 years ago

@kromtech/js-sql-parser v1.0.16

Weekly downloads
6
License
ISC
Repository
github
Last release
5 years ago

js-sql-parser

parse / stringify sql (select grammar) in js.

Build Status NPM Version NPM Downloads

sql grammar follows https://dev.mysql.com/doc/refman/5.7/en/select.html

commonjs usage

npm install --save js-sql-parser

const parser = require('js-sql-parser');
const ast = parser.parse('select * from dual');

console.log(JSON.stringify(ast, null, 2));

ast.value.selectItems.value[0].value = 'foo';
ast.value.from.value[0].value.value.value = 'bar';

console.log(parser.stringify(ast));
// SELECT foo FROM bar

script tag

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

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

AMD supported

...

unsupported grammar currently

  • Hexadecimal Literals as x'01af' X'01af', but 0x01af is supported.
  • keyword COLLATE.
  • parammarker: keyword PREPARE / EXECUTE / DEALLOCATE
  • variable: keyword SET / CREATE PROCEDURE / CREATE FUNCTION
  • identifier expr: ODBC escape syntax
  • matchexpr: Full-Text Search Functions. // to support
  • intervalexpr: Date INTERVAL keyword. // to support
  • into outfile: INTO OUTFILE keyword. // to support

TODO

  • ${value} like value place holder support.

Build

  • Run npm run build to build the distributable.

LICENSE

MIT

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago