packages feed

DBlimited (empty) → 0.1

raw patch · 4 files changed

+163/−0 lines, 4 filesdep +basedep +containersdep +parsecsetup-changed

Dependencies added: base, containers, parsec

Files

+ DBlimited.cabal view
@@ -0,0 +1,61 @@+-- DBlimited.cabal auto-generated by cabal init. For additional+-- options, see+-- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr.+-- The name of the package.+Name:                DBlimited++-- The package version. See the Haskell package versioning policy+-- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for+-- standards guiding when and how versions should be incremented.+Version:             0.1++-- A short (one-line) description of the package.+Synopsis:            A command-line SQL interface for flat files (tdf,csv,etc.)++-- A longer description of the package.+Description:         DBlimited requires a schema file defining the psuedo-tables. Each table is actually a flat file with a name, absolute path, delimiter character, and column definition.++-- URL for the project homepage or repository.+Homepage:            http://projects.haskell.org/DBlimited/++-- The license under which the package is released.+License:             BSD3++-- The file containing the license text.+License-file:        LICENSE++-- The package author(s).+Author:              John P Mayer++-- An email address to which users can send suggestions, bug reports,+-- and patches.+Maintainer:          jpmayer@seas.upenn.edu++-- A copyright notice.+-- Copyright:           ++Category:            Database++Build-type:          Simple++-- Extra files to be distributed with the package, such as examples or+-- a README.+-- Extra-source-files:  ++-- Constraint on the version of Cabal needed to build this package.+Cabal-version:       >=1.2+++Executable DBlimited+  -- .hs or .lhs file containing the Main module.+  Main-is:           DBlimited.hs+  +  -- Packages needed in order to build this package.+  Build-depends:     containers, base >= 2 && < 4, parsec+  +  -- Modules not exported by this package.+  -- Other-modules:       +  +  -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.+  -- Build-tools:         +  
+ DBlimited.hs view
@@ -0,0 +1,70 @@+{-+  Main+-}++module Main where++import Utils+import Schema+import Query++import System.IO+import System.Exit+import qualified Data.Map as M++runQuery :: Schema -> String -> IO ()+runQuery schema queryString = do+  query <- (getQuery schema queryString)+  evalQuery query++printHelp :: IO ()+printHelp = do+  putStrLn "Commands:"+  putStrLn ":h               | Display this help"+  putStrLn ":s               | Print details about the schema"+  putStrLn ":t <tablenames>  | Print details about <tablename>"+  putStrLn ":r               | Reload the schema"+  putStrLn ":q               | ToDo: quit"+  putStrLn "<querystring> | ToDo: run SELECT query"++runCommand :: Schema -> [String] -> IO ()+runCommand _ [] = return ()+runCommand schema (ident:as)+    | ident == ":h" = printHelp+    | ident == ":s" = prettyPrintSchema schema+    | ident == ":t" = prettyPrintTables.(map (\t -> M.lookup t schema))$as+    | ident == ":r" = setup+    | ident == ":q" = exitSuccess+    | otherwise     = runQuery schema (unwords (ident:as))++commandLoop :: Schema -> IO ()+commandLoop schema = do+  putStr "dbl# "+  command <- getLine+  runCommand schema (words command)+  putStrLn ""+  commandLoop schema++setup :: IO ()+setup = do+  putStrLn "\nEnter path to schema file"+  schemaPath <- getLine+  putStrLn ("\nTrying to load schema file \"" ++ schemaPath ++ "\"")+  schema <- readSchema schemaPath+  putStrLn "Loaded Schema"+  prettyPrintSchema schema+  putStrLn "Enter ':h' for help and a list of commands\n"+  commandLoop schema++sampleSetup :: IO ()+sampleSetup = do+  schema <- sampleSchema+  putStrLn "Loaded Schema"+  prettyPrintSchema schema+  putStrLn "Enter ':h' for help and a list of commands\n"+  commandLoop schema++main :: IO ()+main = do+  hSetBuffering stdout NoBuffering+  setup
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c)2010, John P Mayer++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 name of John P Mayer nor the names of other+      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,2 @@+import Distribution.Simple+main = defaultMain