JulesGuesnon / pg_query-ocaml

OCaml bindings for libpg_query

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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"

About

OCaml bindings for libpg_query

License:Other


Languages

Language:C 83.7%Language:PLpgSQL 15.6%Language:Ruby 0.5%Language:Makefile 0.1%Language:OCaml 0.1%Language:C++ 0.0%Language:Shell 0.0%