# pg-query-native

> The real PostgreSQL query parser

Latest version **1.3.1** (published 2021-09-29) · BSD license · 0 weekly downloads

## Install

```sh
npm install pg-query-native
pnpm add pg-query-native
yarn add pg-query-native
bun add pg-query-native
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2021-09-29 |
| First published | 2015-11-14 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 10 MB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Author | Zac McCormick |
| Maintainers | zhm |
| Keywords | sql, postgres, postgresql, pg, query, database |

## Links

- npm: https://www.npmjs.com/package/pg-query-native
- Repository: https://github.com/zhm/node-pg-query-native
- Homepage: http://github.com/zhm/node-pg-query-native
- Issues: https://github.com/zhm/node-pg-query-native/issues
- npm.io page: https://npm.io/package/pg-query-native

## Dependencies (3)

- [nan](https://npm.io/package/nan.md) ^2.15.0
- [bindings](https://npm.io/package/bindings.md) ^1.5.0
- [node-gyp](https://npm.io/package/node-gyp.md) ^8.2.0

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.3.1 (latest) — 2021-09-29
- 1.3.0 — 2021-09-29
- 1.2.0 — 2019-06-15
- 1.1.0 — 2016-06-03
- 0.0.5 — 2015-11-19
- 0.0.4 — 2015-11-16
- 0.0.3 — 2015-11-14
- 0.0.2 — 2015-11-14
- 0.0.1 — 2015-11-14

## README

# pg-query-native [![Build Status](https://travis-ci.org/zhm/node-pg-query-native.svg?branch=master)](https://travis-ci.org/zhm/node-pg-query-native)

The real PostgreSQL parser for nodejs.

This is based on the output of [libpg_query](https://github.com/lfittl/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](https://github.com/lfittl).

## Installation

```sh
npm install pg-query-native
```

### Documentation

### `query.parse(query)`

Parses the query and returns the parse tree.

### Parameters

| parameter            | type               | description                                               |
| -------------------- | ------------------ | --------------------------------------------------------- |
| `query`              | String             | SQL query                                                 |

Returns an object in the format:

```
{ query: <query|Object>,
  error: { message: <message|String>,
           fileName: <fileName|String>,
           lineNumber: <line|Number>,
           cursorPosition: <cursor|Number> }
```

## Example

```js
var parse = require('pg-query-native').parse;

console.log(parse('select 1').query);
```

## Related

* [libpg_query](https://github.com/lfittl/libpg_query)
* [pg_query](https://github.com/lfittl/pg_query)
* [pg_query.go](https://github.com/lfittl/pg_query.go)

---
_Source: https://npm.io/package/pg-query-native · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
