The sqlite-simple package

[Tags: bsd3, library]

Mid-level SQLite client library, based on postgresql-simple.

Main documentation: Database.SQLite.Simple

For more info, browse to for examples & more information.

[Skip to ReadMe]


Change logNone available
Dependenciesbase (<5), bytestring (>=0.9), containers, direct-sqlite (>=2.3.4 && <2.4), old-locale (>=, text (>=0.11), time, transformers [details]
Copyright(c) 2011 MailRank, Inc., (c) 2011-2012 Leon P Smith, (c) 2012-2013 Janne Hellsten
AuthorBryan O'Sullivan, Leon P Smith, Janne Hellsten
MaintainerJanne Hellsten <>
Home page
Bug tracker
Source repositoryhead: git clone
UploadedSat Sep 14 20:11:56 UTC 2013 by JanneHellsten
DistributionsLTSHaskell:, NixOS:, Stackage:
Downloads5805 total (233 in last 30 days)
0 []
StatusDocs uploaded by user
Build status unknown [no reports yet]




Maintainers' corner

For package maintainers and hackage trustees

Readme for sqlite-simple-

sqlite-simple: mid-level bindings to the sqlite database

This library is a mid-level Haskell binding to the SQLite database.

Sqlite-simple provides a convenient API to sqlite that does some level of 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 has been fairly well unit tested. It's also been benchmarked using db-bench which is a performance comparison suite for measuring database access overhead when using the various Haskell database libraries.

Build Status


You can install sqlite-simple from Hackage with:

cabal install sqlite-simple

A Windows user? It works but please see this note on direct-sqlite Windows installation.

Examples of use

Create a test database by copy&pasting the below snippet to your shell:

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

..and access it in Haskell:

{-# LANGUAGE OverloadedStrings #-}
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

More simple usage examples can be found from sqlite-simple unit tests.


The development roadmap for sqlite-simple is mostly captured in the github issue database.

I'm happy to receive bug reports, fixes, documentation enhancements, and other improvements.

Please report bugs via the github issue tracker.

For general database issues with a Haskell focus, I recommend sending e-mail to the database-devel mailing list.


If you send pull requests for new features, it'd be great if you could also develop unit tests for any such features.


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 borrow code and documentation directly from both of these ancestor libraries.

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

SQLite is rather weakly-typed and thus the SQL to Haskell type strictness of the parent projects does not necessarily apply to this package.