Package Exports
- libpg-query
- libpg-query/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (libpg-query) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
libpg-query
The real PostgreSQL parser, exposed for nodejs.
Primarily used for the node.js parser and deparser pgsql-parser
Building a binary distribution
- Install requirements (
npm i
) npx node-pre-gyp rebuild package
- With appropriate AWS credentials configured,
npx node-pre-gyp publish
Or you can run the scripts
npm run binary:build
npm run binary:publish
Installation
npm install libpg-query
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
const parser = require('libpg-query');
parser.parseQuery('select 1').then(console.log);
Versions
Our latest is built with 15-latest
branch from libpg_query
PostgreSQL Major Version | libpg_query | Status | npm |
---|---|---|---|
15 | 15-latest | Supported | latest |
14 | 14-latest | Supported | libpg-query@14.0.0 |
13 | 13-latest | Supported | libpg-query@13.3.1 |
12 | (n/a) | Not supported | |
11 | (n/a) | Not supported | |
10 | 10-latest | Not supported | @1.3.1 (tree) |
Related
Credit
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.
Additional thanks for node binding Ethan Resnick.