package pg_query

  1. Overview
  2. Docs
Bindings to libpg_query for parsing PostgreSQL

Install

Dune Dependency

Authors

Maintainers

Sources

0.9.4.tar.gz
md5=219f416bcaa6b3a25dcc088b408d559f
sha512=64aa1d4b99a0afe564155283fcbec6f3b59c6c0c34688cc1a2859603dd9a32ecc0a4a519bdda6437724b4263d78b4d0c3e972b4f301e203e0703cb2c326efaf0

Description

OCaml bindings to libpg_query for parsing PostgreSQL, and a command-line tool that uses them

Published: 22 Jan 2020

README

pg_query-ocaml

Bindings for pg_query for parsing PostgreSQL. Documentation is here.

Usage

This provides a library that can be used in OCaml code like so:

let statement = "SELECT user, email FROM users WHERE id = 7"

let () =
  match Pg_query.parse statement with
  | Ok parse_tree -> use parse_tree
  | Error error_message -> use error_message

and a command-line utility:

$ echo "SELECT * FROM users" >> good.sql
$ echo "SELECT * FFROM users" >> bad.sql
$ pg_check good.sql bad.sql
[{"RawStmt": {"stmt": {"SelectStmt": {"targetList": [{"ResTarget": {"val": {"ColumnRef": {"fields": [{"A_Star": {}}], "location": 7}}, "location": 7}}], "fromClause": [{"RangeVar": {"relname": "users", "inh": true, "relpersistence": "p", "location": 14}}], "op": 0}}}}]
syntax error at or near "FFROM"

Dependencies (6)

  1. ppx_deriving >= "4.2"
  2. ctypes-foreign
  3. ctypes >= "0.14.0"
  4. core < "v0.15"
  5. dune >= "2.0"
  6. ocaml >= "4.07"

Dev Dependencies

None

Used by (1)

  1. ppx_rapper < "3.1.0"

Conflicts

None

OCaml

Innovation. Community. Security.