Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
libpg-query
Advanced tools
The real PostgreSQL parser, exposed for nodejs.
Primarily used for the node.js parser and deparser pgsql-parser
Install node-gyp globally
npm install node-gyp -g
git clone -b 10-latest git://github.com/lfittl/libpg_query
cd libpg_query
make
Then get the .a
file and drop it in the folder in this repo.
npm install libpg-query
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.
const parser = require('libpg-query');
parser.parseQuery('select 1').then(console.log);
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.
FAQs
The real PostgreSQL query parser
The npm package libpg-query receives a total of 20,524 weekly downloads. As such, libpg-query popularity was classified as popular.
We found that libpg-query demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.