package pg_query

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

Install

Dune Dependency

Authors

Maintainers

Sources

0.9.6.tar.gz
md5=fe2494f9230c587b0ef13f6722e56967
sha512=db0e3370591cf3133594abc0c9e6609f163d478ad2e1d6a62e97d0e3bf4e64935b7b6d7fddc5ace95b1d2de458822c08c7e8d8aa8b328a36e919380c4fa74d37

Description

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

Published: 19 Oct 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. cmdliner >= "1.0.0"
  5. dune >= "2.0"
  6. ocaml >= "4.07"

Dev Dependencies (1)

  1. alcotest with-test

Used by (1)

  1. ppx_rapper

Conflicts

None

OCaml

Innovation. Community. Security.