package pg_query

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

Install

Dune Dependency

Authors

Maintainers

Sources

0.9.5.tar.gz
md5=26278704b2df581a305c91ad9f596d2e
sha512=d509459e17402b32a1e92de7b63c592e0a1d42273d7ea0223b5b2f06e3f2b319d909beedffe71a12b58630bf4c877f8ca58af42684fab246ca9ab5cee3fc78ef

Description

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

Published: 28 Jul 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.