homepage: https://github.com/ruby0b/sqlite-simple-interpolate
changelog-type: markdown
hash: 97d966558c585a58a34bab41a0bb0a7b2f35544f7a1c4cf664646350e26c4b2e
test-bench-deps: {}
maintainer: ruby0b
synopsis: Interpolated SQLite queries via quasiquotation
changelog: |
  # Changelog

  ## 0.1.0

  * Initial version.
basic-deps:
  base: '>=4.5 && <5'
  sqlite-simple: '>=0.1'
  parsec: ^>=3.1
  mtl: '>=2.1 && <2.3'
  haskell-src-meta: '>=0.6 && <0.9'
  template-haskell: '>=2.17 && <2.19'
all-versions:
- '0.1'
author: ruby0b
latest: '0.1'
description-type: markdown
description: |
  # `sqlite-simple-interpolate`

  Write natural SQL statements in Haskell using QuasiQuoters!

  ```haskell
  {-# LANGUAGE QuasiQuotes #-}
  module Main where

  import Data.Char (toLower)
  import qualified Database.SQLite.Simple as SQL
  import Database.SQLite.Simple.QQ.Interpolated
  import Control.Exception (bracket)

  (&) = flip ($)
  infixl 1 &

  main :: IO ()
  main = bracket (SQL.open ":memory:") SQL.close $ \conn -> do
    conn & [iexecute|CREATE TABLE people (name TEXT, age INTEGER)|]
    conn & [iexecute|INSERT INTO people VALUES ("clive", 40)|]
    -- you can always use 'isql' directly but you'll have to use uncurry:
    (uncurry $ SQL.execute conn) [isql|INSERT INTO people VALUES ("clive", 32)|]

    ageSum <- conn & [ifold|SELECT age FROM people|] 0 (\acc (SQL.Only x) -> pure (acc + x))
    print ageSum

    let limit = 1
    ages <- conn & [iquery|SELECT age FROM people WHERE name = ${map toLower "CLIVE"} LIMIT ${limit}|]
    print (ages :: [SQL.Only Int])
  ```

  ## Acknowledgements
  This library is a fork of [`postgresql-simple-interpolate`](https://github.com/3noch/postgresql-simple-interpolate), adapted for use with `sqlite-simple`.

  The original itself is basically just a copy of the [`here` package](https://github.com/tmhedberg/here) by Taylor M. Hedberg with slight modifications!
license-name: BSD-3-Clause

Update from Hackage at 2022-05-30T03:26:55Z
Update from Hackage at 2022-05-30T03:26:55Z
