sqlite-simple: Mid-Level SQLite client library

[ bsd3, database, library ] [ Propose Tags ]

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

Main documentation (with examples): Database.SQLite.Simple

You can view the project page at http://github.com/nurpax/sqlite-simple for more information.


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.2.0.0, 0.2.1.0, 0.3.0.0, 0.4.0.0, 0.4.1.0, 0.4.2.0, 0.4.3.0, 0.4.3.1, 0.4.4.0, 0.4.5.0, 0.4.5.1, 0.4.5.2, 0.4.6.0, 0.4.6.1, 0.4.7.0, 0.4.8.0, 0.4.9.0, 0.4.10.0, 0.4.11.0, 0.4.12.0, 0.4.12.1, 0.4.13.0, 0.4.14.0, 0.4.15.0, 0.4.16.0, 0.4.17.0, 0.4.18.0, 0.4.18.2, 0.4.19.0 (info)
Change log changelog
Dependencies attoparsec (>=0.10.3), base (>=4.5 && <4.11), blaze-builder, blaze-textual, bytestring (>=0.9), containers, direct-sqlite (>=2.3.13 && <2.4), text (>=0.11), time, transformers [details]
License BSD-3-Clause
Copyright (c) 2011 MailRank, Inc., (c) 2011-2012 Leon P Smith, (c) 2012-2014 Janne Hellsten
Author Bryan O'Sullivan, Leon P Smith, Janne Hellsten
Maintainer Janne Hellsten <jjhellst@gmail.com>
Revised Revision 1 made by GeorgeWilson at 2018-03-27T07:18:01Z
Category Database
Home page http://github.com/nurpax/sqlite-simple
Bug tracker http://github.com/nurpax/sqlite-simple/issues
Source repo head: git clone http://github.com/nurpax/sqlite-simple
Uploaded by JanneHellsten at 2016-11-17T21:26:28Z
Distributions Arch:0.4.19.0, LTSHaskell:0.4.19.0, NixOS:0.4.19.0, Stackage:0.4.19.0
Reverse Dependencies 32 direct, 400 indirect [details]
Downloads 38931 total (269 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-11-17 [all 1 reports]

Readme for sqlite-simple-0.4.10.0

[back to package description]

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 sqlite-simple API reference contains more examples of use and information on its features.

The library is well tested and stable. The library should also be reasonably performant. You can find its benchmark suite here: db-bench. You can read more about sqlite-simple's expected performance in my blog about sqlite-simple performance against direct-sqlite, Python and C.

Build Status

Coverage Status

Installation

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.

Development

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.

Contributing

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

Credits

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.