haskelldb-dynamic 0.10 → 1.0.0
raw patch · 4 files changed
+64/−113 lines, 4 filesdep ~basedep ~haskelldbnew-component:exe:DBDirect-dynamicnew-uploader
Dependency ranges changed: base, haskelldb
Files
- DBDirect.hs +3/−81
- Database/HaskellDB/DynConnect.hs +8/−16
- LICENSE +31/−0
- haskelldb-dynamic.cabal +22/−16
DBDirect.hs view
@@ -1,83 +1,5 @@--------------------------------------------------------------- |--- Module : Main--- Copyright : Daan Leijen (c) 1999, daan@cs.uu.nl--- HWT Group (c) 2003,--- Bjorn Bringert (c) 2005-2006, bjorn@bringert.net--- License : BSD-style--- --- Maintainer : haskelldb-users@lists.sourceforge.net--- Stability : experimental--- Portability : portable------ DBDirect generates a Haskell module from a database.--- It first reads the system catalog of the database into--- a 'Catalog' data type. After that it pretty prints that--- data structure in an appropiate Haskell module which--- can be used to perform queries on the database.-----------------------------------------------------------------module Main where--import Data.List-import System.Environment (getArgs)-import System.Exit (exitFailure)-import System.IO--import Database.HaskellDB import Database.HaskellDB.DynConnect-import Database.HaskellDB.DBSpec-import Database.HaskellDB.DBSpec.PPHelpers-import Database.HaskellDB.DBSpec.DBSpecToDBDirect--createModules m useBStrT db = - do- putStrLn "Getting database info..."- spec <- dbToDBSpec useBStrT m db- putStrLn "Writing modules..."- dbInfoToModuleFiles "." m spec---- | Command line driver-main = do- putStrLn "DB/Direct: Daan Leijen (c) 1999, HWT (c) 2003-2004,"- putStrLn " Bjorn Bringert (c) 2005-2006"- putStrLn ""- args <- getArgs- let (flags,args') = partition ("-" `isPrefixOf`) args- useBStrT = "-b" `elem` flags- case args' of- [m,d,o] -> - do- let opts = splitOptions o- putStrLn "Connecting to database..."- dynConnect_ d opts (createModules m useBStrT)- putStrLn "Done!"- _ -> - do- showHelp- exitFailure--splitOptions :: String -> [(String,String)]-splitOptions = map (split2 '=') . split ','--split :: Char -> String -> [String]-split _ [] = []-split g xs = y : split g ys- where (y,ys) = split2 g xs--split2 :: Char -> String -> (String,String)-split2 g xs = (ys, drop 1 zs)- where (ys,zs) = break (==g) xs+import Database.HaskellDB.DBDirect --- | Shows usage information-showHelp = mapM_ (hPutStrLn stderr) t- where- t = ["Usage: DBDirect [-b] <module> <driver> <options>",- "",- "-b Use bounded string types",- "<driver> One of: WX, HSQL.MySQL, HDBC.PostgreSQL, etc",- "<options> Driver dependent,e.g.",- " WX: dsn=<dsn>,uid=<uid>,pwd=<pwd>",- " HSQL.MySQL: server=<server>,db=<db>,uid=<uid>,pwd=<pwd>",- " HDBC.PostgreSQL: host=<server>,dbname=<db>,user=<uid>,password=<pwd>"]+main :: IO ()+main = dbdirect driver
Database/HaskellDB/DynConnect.hs view
@@ -14,6 +14,7 @@ ----------------------------------------------------------- module Database.HaskellDB.DynConnect (+ driver, dynConnect, dynConnect_ ) where@@ -22,26 +23,17 @@ import Database.HaskellDB.DriverAPI import Database.HaskellDB.Version -import System.Plugins (loadPackage,unloadPackage,resolveObjs,loadFunction_)-import System.Plugins.Utils (encode)+import System.Plugins (loadPackageFunction) import Control.Monad.Trans (MonadIO, liftIO) import Data.Char import Data.List (isPrefixOf) ---- | Loads a function from a package module, given the package name,--- module name and symbol name.-loadPackageFunction :: MonadIO m => - String -- ^ Package name, including version number.- -> String -- ^ Module name- -> String -- ^ Symbol to lookup in the module- -> m (Maybe a)-loadPackageFunction pkgName moduleName functionName =- do- liftIO $ loadPackage pkgName- liftIO $ resolveObjs (unloadPackage pkgName)- liftIO $ loadFunction_ (encode moduleName) functionName+driver :: DriverInterface+driver = defaultdriver {+ connect = \opts f -> do [driver] <- getOptions ["driver"] opts+ dynConnect_ driver opts f+ } -- | Loads a driver by package and module name. dynConnect :: MonadIO m => @@ -52,7 +44,7 @@ -> m a dynConnect p m opts f = do- res <- loadPackageFunction p m "driver"+ res <- liftIO $ loadPackageFunction p m "driver" v <- case res of Nothing -> fail $ "Couldn't load " ++ m ++ ".driver" ++ " from package " ++ p
+ 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.
haskelldb-dynamic.cabal view
@@ -1,23 +1,29 @@ Name: haskelldb-dynamic-Version: 0.10+Version: 1.0.0+Cabal-version: >= 1.6+Homepage: https://github.com/m4dc4p/haskelldb+Build-type: Simple 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, plugins-Extensions: ExistentialQuantification,- OverlappingInstances,- UndecidableInstances,- MultiParamTypeClasses+License-file: LICENSE Synopsis: HaskellDB support for the dynamically loaded drivers.-Exposed-Modules:- Database.HaskellDB.DynConnect-ghc-options: -O2+Category: Database -executable: DBDirect-main-is: DBDirect.hs-Extensions: ExistentialQuantification,- OverlappingInstances,- UndecidableInstances,- MultiParamTypeClasses-ghc-options: -O2+Library+ Build-depends: haskell98, mtl, haskelldb, plugins, base >= 3 && < 5 + Extensions: ExistentialQuantification,+ OverlappingInstances,+ UndecidableInstances,+ MultiParamTypeClasses+ Exposed-Modules:+ Database.HaskellDB.DynConnect++Executable DBDirect-dynamic+ Main-is: DBDirect.hs+ Build-depends: haskelldb==0.11++Source-repository head+ Type: git+ Location: https://github.com/m4dc4p/haskelldb