[Haskell] ANNOUNCE: sqlite-simple mid-level API to the sqlite database

Janne Hellsten jjhellst at gmail.com
Sun Sep 30 09:38:15 CEST 2012

sqlite-simple provides a convenient API to sqlite that performs
automatic data conversion between the database and Haskell types. The
API has been modeled directly after postgresql-simple which in turn
borrows from mysql-simple.

The library is available on hackage at


 * *

Notable changes since the previous announcement:

- Better thought out module exports - this release makes it possible
to add user-defined FromField instances (see
- sqlite-simple was upgraded to use the latest direct-sqlite 2.2
- As part of the release, the Snap sqlite-simple plugin
snaplet-sqlite-simple was upgraded to the latest sqlite-simple.  See

 * *

Example usage

First create a test database..

sqlite3 test.db "CREATE TABLE test (id INTEGER PRIMARY KEY, str text);\
  INSERT INTO test (str) VALUES ('test string');"

..and access it in Haskell:

import Control.Applicative
import Database.SQLite.Simple
import Database.SQLite.Simple.FromRow

data TestField = TestField Int String
                 deriving (Show)

instance FromRow TestField where
  fromRow = TestField <$> field <*> field

main :: IO ()
main = do
  conn <- open "test.db"
  execute conn "INSERT INTO test (str) VALUES (?)"
    (Only ("test string 2" :: String))
  r <- query_ conn "SELECT * from test" :: IO [TestField]
  mapM_ print r
  close conn

 * *

A lot of the code is directly borrowed from mysql-simple by Bryan
O'Sullivan and from postgresql-simple by Leon P. Smith. Like Leon in
postgresql-simple, I've borrowed code and documentation directly from
both of these ancestor libraries.

This package builds on top of the direct-sqlite package by Irene

Thanks to all of the above for helpful comments, features and code

 * *

Bugs, feature requests?

I'm happy to receive bug reports via github on:


For discussion, I recommend the database-devel mailing list:



More information about the Haskell mailing list