A parser, pretty printer, and type checker for SQL written in Haskell. Supports PostgreSQL SQL and PL/pgSQL syntax. BSD licensed.
This is the documentation for version 0.4.0. Documentation for other versions is available here: http://jakewheat.github.io/hssqlppp/.
Possible uses of this library include:
With some extra work:
Pre-alpha. Support for parsing SQL is patchy, but not too bad. Supports queries/DML and DDL. Here is an extract from the parsing tests which gives some examples of what can currently be parsed:
The type checker is currently still being fixed after some reworking of parsing and ast types. It should handle a lot of queries and dml fine though.
Extract from the type checking tests:
Currently limited support for quasiquoting, here are the extracts from the tests:
The pretty printer should support everything the parser supports (i.e. it pretty prints code which both the parser and Postgres understand).
Catalog information is limited, supports the type checking. Some information is collected on scalar types, domains, composite types, casts, tables, views and functions.
This project is currently developed on GHC 7.2.1. 7.0.x should be fine, 6.12.x might take a small amount of work.
To install use
cabal install hssqlppp
Some notes on hacking on hssqlppp itself
Homepage: http://jakewheat.github.com/hssqlppp/
Hackage: http://hackage.haskell.org/package/hssqlppp
Repository: https://github.com/JakeWheat/hssqlppp
Changes: https://github.com/JakeWheat/hssqlppp/blob/master/CHANGES
Use the github issue tracker. Please supply an example of SQL which doesn't parse/typecheck correctly where relevant.
https://github.com/JakeWheat/hssqlppp/issues
Let me know if you're using/ interested in using the library, if you have any problems, bug reports, or suggestions, etc.. All contributions, comments and criticism welcome:
jakewheatmail@gmail.com