sqlite-simple-interpolate-0.1.1: Interpolated SQLite queries via quasiquotation
Safe HaskellNone
LanguageHaskell2010

Database.SQLite.Simple.QQ.Interpolated

Description

Interpolated SQL queries

Synopsis

Documentation

isql :: QuasiQuoter Source #

Quote a SQL statement with embedded antiquoted expressions.

The result of the quasiquoter is a tuple, containing the statement string and a list of parameters. For example:

[isql|SELECT field FROM table WHERE name = ${map toLower ELLIOT} LIMIT ${10}|]

produces

("SELECT field FROM table WHERE name = ? LIMIT ?", [toField ((map toLower) ELLIOT), toField 10])

How the parser works:

Any expression occurring between ${ and } will be replaced with a ? and passed as a query parameter.

Characters preceded by a backslash are treated literally. This enables the inclusion of the literal substring ${ within your quoted text by writing it as \${. The literal sequence \${ may be written as \\${.

Note: This quasiquoter is a wrapper around sql.

This quasiquoter only works in expression contexts and will throw an error at compile time if used in any other context.

quoteInterpolatedSql :: String -> Q Exp Source #

The internal parser used by isql.

iquery :: QuasiQuoter Source #

Invokes query with arguments provided by isql. The result is of type '(Connection -> IO [r])'.

iexecute :: QuasiQuoter Source #

Invokes execute with arguments provided by isql The result is of type '(Connection -> IO ())'.

ifold :: QuasiQuoter Source #

Invokes fold with arguments provided by isql. The result is of type 'a -> (a -> row -> IO a) -> Connection -> IO a'.