haskelldb-hsql-oracle (empty) → 1.0.0
raw patch · 5 files changed
+151/−0 lines, 5 filesdep +basedep +haskelldbdep +haskelldb-hsqlsetup-changed
Dependencies added: base, haskelldb, haskelldb-hsql, hsql, hsql-oracle, mtl
Files
- DBDirect.hs +5/−0
- Database/HaskellDB/HSQL/Oracle.hs +87/−0
- LICENSE +31/−0
- Setup.hs +4/−0
- haskelldb-hsql-oracle.cabal +24/−0
+ DBDirect.hs view
@@ -0,0 +1,5 @@+import Database.HaskellDB.HSQL.Oracle+import Database.HaskellDB.DBDirect++main :: IO ()+main = dbdirect driver
+ Database/HaskellDB/HSQL/Oracle.hs view
@@ -0,0 +1,87 @@+-----------------------------------------------------------+-- |+-- Module : Database.HaskellDB.HSQL.Oracle+-- Copyright : HWT Group 2003,+-- Bjorn Bringert 2006,+-- Henning Thielemann 2008+-- License : BSD-style+--+-- Maintainer : haskelldb-users@lists.sourceforge.net+-- Stability : experimental+-- Portability : non-portable+--+-----------------------------------------------------------++module Database.HaskellDB.HSQL.Oracle (+ OracleOptions(..),+ oracleConnect,+ DriverInterface(..),+ driver+ ) where++import Database.HaskellDB.Database+import Database.HaskellDB.HSQL+import Database.HaskellDB.DriverAPI+import Database.HaskellDB.Sql.Generate (SqlGenerator)+import qualified Database.HSQL.Oracle as Oracle+import qualified Database.HSQL as HSQL+import Database.HSQL.Types (connTables)+import Control.Exception (bracket)+++data OracleOptions =+ OracleOptions {+ dsn :: String, -- ^ name binding in Oracle+ uid :: String, -- ^ user id+ pwd :: String -- ^ password+ }++oracleConnect ::+ MonadIO m =>+ SqlGenerator -> OracleOptions -> (Database -> m a) -> m a+oracleConnect gen opts =+ hsqlConnect gen (Oracle.connect (dsn opts) (uid opts) (pwd opts))+{-+HSQL's connTables asks for COREDB_SYSTEM,+but newer Oracle versions (e.g. 10g) do not have it.+Instead they provide a USER_TABLES.+This should clearly be fixed in HSQL not here.++ let connector = Oracle.connect (dsn opts) (uid opts) (pwd opts)+ getTables =+ bracket connector HSQL.disconnect $ \c ->+-- inTransaction c $ \c ->+ retrieveTables c+ in hsqlConnect gen+ (fmap (\c -> c {connTables = getTables}) connector)++retrieveTables :: HSQL.Connection -> IO [String]+retrieveTables c =+ HSQL.query c "select table_name from user_tables" >>=+ HSQL.collectRows (flip HSQL.getFieldValue "TABLE_NAME")+-}++options :: [(String, String)]+options =+ ("dsn", "Data Source Name") :+ ("uid", "User") :+ ("pwd", "Password") :+ []++oracleConnectOpts ::+ MonadIO m =>+ [(String,String)] -> (Database -> m a) -> m a+oracleConnectOpts opts f =+ do+ [a,b,c] <- getAnnotatedOptions options opts+ g <- getGenerator opts+ oracleConnect g+ (OracleOptions+ {dsn = a,+ uid = b,+ pwd = c}) f++-- | This driver requires the following options:+-- "dsn", "uid", "pwd"+driver :: DriverInterface+driver = defaultdriver { connect = oracleConnectOpts, requiredOptions = options }
+ LICENSE view
@@ -0,0 +1,31 @@+Copyright (c) 1999 Daan Leijen, daan@cs.uu.nl+Copyright (c) 2003-2004 The HaskellDB development team+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are+met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the names of the copyright holders nor the names of the+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,4 @@+#!/usr/bin/env runghc++import Distribution.Simple+main = defaultMain
+ haskelldb-hsql-oracle.cabal view
@@ -0,0 +1,24 @@+Name: haskelldb-hsql-oracle+Version: 1.0.0+Cabal-version: >= 1.6+Build-type: Simple+Copyright: The authors+Homepage: https://github.com/m4dc4p/haskelldb+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, Henning Thielemann+License: BSD3+License-file: LICENSE+Synopsis: HaskellDB support for the HSQL Oracle driver.+Category: Database++Library+ Build-depends: base >= 3 && < 5, mtl, haskelldb==0.11, haskelldb-hsql==0.11, hsql, hsql-oracle+ Exposed-Modules:+ Database.HaskellDB.HSQL.Oracle++Executable DBDirect-hsql-oracle+ Main-is: DBDirect.hs++Source-repository head+ Type: git+ Location: https://github.com/m4dc4p/haskelldb