node-pgparser
Parse PostgreSQL statements in Javascript!
pgparser
is basically just lib_pgquery ported to Javascript using Emscripten, with a tiny bit of glue! It is a direct port of PostgreSQL's query parser. The output format is a JSON representation of the parse tree.
Note that this is very similar to pg-query-parser. It has the advantage of being plain JS, so it should run fine in browsers (although it's quite large). The drawback of this package is that I haven't implemented a way to transform the parse tree back into SQL (yet!).
Usage
Currently, pgparser
simply parses queries into a parse tree. It returns a Promise when invoked:
const pgparser = ; let sql = ` SELECT id, first_name FROM users`; pgparser;
The parse tree for the sample query is below: