Safe Haskell | None |
---|---|
Language | Haskell2010 |
PgQuery
Synopsis
- module PgQuery.Internal.Proto.PgQuery
- module PgQuery.Internal.Proto.PgQuery_Fields
- parseSql :: String -> IO (Either String ParseResult)
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.