pg-query-0.0.1.1: Parse PostgreSQL DDL and DML: Haskell bindings for libpg_query
Safe HaskellNone
LanguageHaskell2010

PgQuery

Synopsis

Documentation

parseSql :: String -> IO (Either String ParseResult) Source #

Parses SQL, returning the internal PostgreSQL parse tree as a ParseResult.

Here's an example:

    main :: IO ()
    main = do
      eResult <- parseSql "select u.name, u.address from users u where u.id = $1"
      case eResult of
        Left err -> error err
        Right result -> print result
  

To make meaningful use of the ParseResult, you'll want to use Control.Lens in conjunction with the functions provided in PgQuery.Internal.Proto.PgQuery_Fields. See here for a tutorial on how to use lenses.

The tests for this library also contain some examples which may serve as a helpful reference.