package pg_query

  1. Overview
  2. Docs
Bindings for pg_query for parsing PostgreSQL

Install

Dune Dependency

Authors

Maintainers

Sources

0.9.3.tar.gz
md5=2c9718078f6956a8bdb87cd6885c7fae
sha512=ac2e76ac5efc07056e28ab71515b26d187f77c2f7c2bf802cfaf3f658d7cf29db635382497cdae64d895c27e32c785f3cc4a68e082507e529da1e344a6ef231d

Description

Published: 20 Dec 2019

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.