hasql-th-0.1.0.1: Template Haskell utilities for Hasql

Safe HaskellNone
LanguageHaskell2010

Hasql.TH

Synopsis

Documentation

readFileAsTransaction :: String -> Q Exp Source

Read an SQL-file, containing multiple statements, and produce a transaction expression.

Allows to store plain SQL in external files and read it at compile time.

E.g.,

migration1 :: Transaction ()
migration1 =
  $(Hasql.TH.readFileAsTransaction "sql/migration-1.sql")

Note that so far this function uses a very simple parsing algorithm to extract individual statements from the file. The algorithm simply splits the contents by the semicolon. So make sure that you only apply it to SQL, which only uses the semicolon for statement-separation.