haskelldb-hsql-sqlite (empty) → 0.10
raw patch · 3 files changed
+80/−0 lines, 3 filesdep +basedep +haskell98dep +haskelldbbuild-type:Customsetup-changed
Dependencies added: base, haskell98, haskelldb, haskelldb-hsql, hsql, hsql-sqlite, mtl
Files
- Database/HaskellDB/HSQL/SQLite.hs +61/−0
- Setup.hs +4/−0
- haskelldb-hsql-sqlite.cabal +15/−0
+ Database/HaskellDB/HSQL/SQLite.hs view
@@ -0,0 +1,61 @@+-----------------------------------------------------------+-- |+-- Module : Database.HaskellDB.HSQL.SQLite+-- Copyright : HWT Group 2003,+-- Bjorn Bringert 2006+-- License : BSD-style+-- +-- Maintainer : haskelldb-users@lists.sourceforge.net+-- Stability : experimental+-- Portability : non-portable+--+-- Interface to SQLite 2 <http://www.hwaci.com/sw/sqlite/>+-- databases.+--+-----------------------------------------------------------+module Database.HaskellDB.HSQL.SQLite (+ SQLiteOptions(..), sqliteConnect,+ DriverInterface(..), driver+ ) where++import Database.HaskellDB.Database+import Database.HaskellDB.HSQL+import Database.HaskellDB.DriverAPI+import Database.HaskellDB.Sql.SQLite as SQLite++import qualified Database.HSQL.SQLite2 as SQLite2 (connect) +import System.IO++data SQLiteOptions = SQLiteOptions { + filepath :: FilePath, -- ^ database file+ mode :: IOMode -- ^ access mode+ }++sqliteConnect :: MonadIO m => SQLiteOptions -> (Database -> m a) -> m a+sqliteConnect opts = + hsqlConnect SQLite.generator (SQLite2.connect (filepath opts) (mode opts))++sqliteConnectOpts :: MonadIO m => [(String,String)] -> (Database -> m a) -> m a+sqliteConnectOpts opts f = + do+ [a,b] <- getOptions ["filepath","mode"] opts+ m <- readIOMode b+ sqliteConnect (SQLiteOptions {filepath = a,+ mode = m}) f++readIOMode :: Monad m => String -> m IOMode+readIOMode s = + case s of+ "r" -> return ReadMode+ "w" -> return WriteMode+ "a" -> return AppendMode+ "rw" -> return ReadWriteMode+ _ -> case reads s of+ [(x,"")] -> return x+ _ -> fail $ "Bad IO mode: " ++ s++-- | This driver requires the following options: +-- "filepath", "mode"+-- The possible values of the "mode" option are "r", "w", "rw"+driver :: DriverInterface+driver = defaultdriver {connect = sqliteConnectOpts}
+ Setup.hs view
@@ -0,0 +1,4 @@+#!/usr/bin/env runghc++import Distribution.Simple+main = defaultMain
+ haskelldb-hsql-sqlite.cabal view
@@ -0,0 +1,15 @@+Name: haskelldb-hsql-sqlite+Version: 0.10+Copyright: The authors+Maintainer: haskelldb-users@lists.sourceforge.net+Author: Daan Leijen, Conny Andersson, Martin Andersson, Mary Bergman, Victor Blomqvist, Bjorn Bringert, Anders Hockersten, Torbjorn Martin, Jeremy Shaw+License: BSD3+build-depends: haskell98, base, mtl, haskelldb, haskelldb-hsql, hsql, hsql-sqlite+Extensions: ExistentialQuantification,+ OverlappingInstances,+ UndecidableInstances,+ MultiParamTypeClasses+Synopsis: HaskellDB support for the HSQL SQLite driver.+Exposed-Modules:+ Database.HaskellDB.HSQL.SQLite+ghc-options: -O2