package pg_query

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

Install

Dune Dependency

Authors

Maintainers

Sources

0.9.7.tar.gz
md5=0f60f8c91c556be3f3a7e8f3f8305bb2
sha512=0efa2224ef75f1cea12437673da677964de0d56616e2166e2a794d6f6fd431b44dade1e18455cfeeab12576265f189030df4cd614f764970113476fc036633d2

README.md.html

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"
OCaml

Innovation. Community. Security.