haskelldb-hdbc-mysql (empty) → 0.1
raw patch · 4 files changed
+87/−0 lines, 4 filesdep +HDBCdep +HDBC-mysqldep +basesetup-changed
Dependencies added: HDBC, HDBC-mysql, base, haskelldb, haskelldb-hdbc, mtl
Files
- DBDirect.hs +5/−0
- Database/HaskellDB/HDBC/MySQL.hs +53/−0
- Setup.hs +4/−0
- haskelldb-hdbc-mysql.cabal +25/−0
+ DBDirect.hs view
@@ -0,0 +1,5 @@+import Database.HaskellDB.HDBC.MySQL+import Database.HaskellDB.DBDirect++main :: IO ()+main = dbdirect driver
+ Database/HaskellDB/HDBC/MySQL.hs view
@@ -0,0 +1,53 @@+-----------------------------------------------------------+-- |+-- Module : Database.HaskellDB.HDBC.MySQL+-- Modified from Database.HaskellDB.HDBC.ODBC by Andrew Miller+-- Copyright : HWT Group (c) 2003, Bjorn Bringert (c) 2006, Andrew Miller (c) 2009+-- License : BSD-style+-- +-- Maintainer : haskelldb-users@lists.sourceforge.net+-- Stability : experimental+-- Portability : portable+--+-----------------------------------------------------------+module Database.HaskellDB.HDBC.MySQL (+ mysqlConnect,+ DriverInterface(..), driver+ ) where++import Database.HaskellDB.Database+import Database.HaskellDB.HDBC+import Database.HaskellDB.DriverAPI+import Database.HaskellDB.Sql.Generate (SqlGenerator)+import Data.List++import Database.HDBC.MySQL++mysqlConnect :: MonadIO m => SqlGenerator -> [(String,String)] -> (Database -> m a) -> m a+mysqlConnect gen opts = hdbcConnect gen (connectMySQL conninfo)+ -- strangely enough, mysql+unixodbc want a semicolon terminating connstring+ where conninfo = foldl' (\info (k,v) ->+ case k+ of+ "host" -> info { mysqlHost = v }+ "user" -> info { mysqlUser = v }+ "password" -> info { mysqlPassword = v }+ "database" -> info { mysqlDatabase = v }+ "port" -> info { mysqlPort = read v }+ "unixSocket" -> info { mysqlUnixSocket = v }+ _ -> info+ ) defaultMySQLConnectInfo opts++options :: [(String, String)]+options =+ []++mysqlConnectOpts :: MonadIO m => [(String,String)] -> (Database -> m a) -> m a+mysqlConnectOpts opts f = + do gen <- getGenerator opts+ let opts' = filter ((/="generator") . fst) opts+ mysqlConnect gen opts' f++-- | This driver passes its options through to HDBC.+driver :: DriverInterface+driver = defaultdriver { connect = mysqlConnectOpts, requiredOptions = options }
+ Setup.hs view
@@ -0,0 +1,4 @@+#!/usr/bin/env runghc++import Distribution.Simple+main = defaultMain
+ haskelldb-hdbc-mysql.cabal view
@@ -0,0 +1,25 @@+Name: haskelldb-hdbc-mysql+Version: 0.1+Cabal-version: >= 1.2+Build-type: Simple+Copyright: The authors+Maintainer: haskelldb-users@lists.sourceforge.net+Author: Andrew Miller, Daan Leijen, Conny Andersson, Martin Andersson, Mary Bergman, Victor Blomqvist, Bjorn Bringert, Anders Hockersten, Torbjorn Martin, Jeremy Shaw+Category: Database+License: BSD3+Synopsis: HaskellDB support for the HDBC MySQL driver.+Description: haskelldb-hdbc-mysql allows the HDBC-mysql package to be used from HaskellDB. This means HaskellDB can be used with MySQL, without going through ODBC.++Library+ Build-depends: + base <= 4,+ mtl, + haskelldb>=0.12,+ haskelldb-hdbc>=0.12,+ HDBC>=2.0.0 && < 2.2.0,+ HDBC-mysql>=0.1+ Exposed-Modules:+ Database.HaskellDB.HDBC.MySQL++Executable DBDirect-hdbc-mysql+ Main-is: DBDirect.hs