@sqlutils/parse
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

pg-plgpsql-query-native

The real PostgreSQL parser for nodejs.

This is based on the output of libpg_query. This wraps the static library output and links it into a node module for use in js.

All credit for the hard problems goes to Lukas Fittl.

Requirements

Instal node-gyp globally

npm install node-gyp -g

Installation

npm install pg-plpgsql-query-native

Documentation

query.parseQuery(sql)/parseQuerySync

Parses the sql and returns a Promise for the parse tree (or returns the parse tree directly in the sync version). May reject with/throw a parse error.

The return value is an array, as multiple queries may be provided in a single string (semicolon-delimited, as Postgres expects).

query.parsePlPgSQL(funcsSql)/query.parsePlPgSQLSync(funcsSql)

Parses the contents of a PL/PGSql function, from a CREATE FUNCTION declaration, and returns a Promise for the parse tree (or returns the parse tree directly in the sync version). May reject with/throw a parse error.

Example

var parse = require('pg-query-native').parseQuery;
parse('select 1').then(console.log);

Related

/@sqlutils/parse/

    Package Sidebar

    Install

    npm i @sqlutils/parse

    Weekly Downloads

    1

    Version

    1.2.1

    License

    BSD

    Unpacked Size

    55.1 kB

    Total Files

    27

    Last publish

    Collaborators

    • ethanresnick