Skip to content

anmonteiro/pg_query-ocaml

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 88.6%
  • C++ 10.2%
  • Ruby 0.6%
  • Objective-C 0.2%
  • PLpgSQL 0.2%
  • OCaml 0.1%
  • Other 0.1%