Database.HDBC: exported symbols usage examples

Symbols

  • SqlColDesc No usage example found for this symbol :( Collapse [-]
    SqlInterval No usage example found for this symbol :( Collapse [-]
    SqlTypeId No usage example found for this symbol :( Collapse [-]
    fromSql See 3 Occurences [+] Collapse [-]
    Found in Database.YeshQL.HDBC from the package yeshql-hdbc
    mkQueryBody query = do
        let (argNames, patterns, funName, queryType) = pqNames query
    
            convert :: ExpQ
            convert = case pqReturnType query of
                        ReturnRowCount tn -> varE 'fromInteger
                        ReturnTuple _ [] -> [|\_ -> ()|]
                        ReturnTuple _ (x:[]) -> [|map (fromSql . head)|]
                        ReturnTuple _ xs ->
                            let varNames = map nthIdent [0..pred (length xs)]
                            in [|map $(lamE
                                        -- \[a,b,c,...] ->
                                        [(listP (map (varP . mkName) varNames))]
                                        -- (fromSql a, fromSql b, fromSql c, ...)
                                        (tupE $ (map (\n -> appE (varE 'fromSql) (varE . mkName $ n)) varNames)))|]
                        ReturnRecord _ x -> [|fromSqlRow|]
            queryFunc = case pqReturnType query of
                            ReturnRowCount _ ->
                                [| \qstr params conn -> $convert <$> run conn qstr params |]
                            ReturnTuple Many _ ->
    

    Found in Database.YeshQL.HDBC from the package yeshql-hdbc
            patterns = map varP argNames
            funName = pqQueryName query
            queryType = pgQueryType query
        in
          (argNames, patterns, funName, queryType)
    
    mkQueryBody :: ParsedQuery -> Q Exp
    mkQueryBody query = do
        let (argNames, patterns, funName, queryType) = pqNames query
    
            convert :: ExpQ
            convert = case pqReturnType query of
                        ReturnRowCount tn -> varE 'fromInteger
                        ReturnTuple _ [] -> [|\_ -> ()|]
                        ReturnTuple _ (x:[]) -> [|map (fromSql . head)|]
                        ReturnTuple _ xs ->
                            let varNames = map nthIdent [0..pred (length xs)]
                            in [|map $(lamE
                                        -- \[a,b,c,...] ->
                                        [(listP (map (varP . mkName) varNames))]
    

    Found in Database.YeshQL.HDBC from the package yeshql-hdbc
    , parseQuery
    , parseQueries
    -- * AST
    , ParsedQuery (..)
    )
    where
    
    import Language.Haskell.TH
    import Language.Haskell.TH.Quote
    #if MIN_VERSION_template_haskell(2,7,0)
    import Language.Haskell.TH.Syntax (Quasi(qAddDependentFile))
    #endif
    import Data.List (isPrefixOf, foldl')
    import Data.Maybe (catMaybes, fromMaybe)
    import Database.HDBC (fromSql, toSql, run, runRaw, ConnWrapper, IConnection, quickQuery')
    import qualified Text.Parsec as P
    import Data.Char (chr, ord, toUpper, toLower)
    import Control.Applicative ( (<$>), (<*>) )
    import System.FilePath (takeBaseName)
    import Data.Char (isAlpha, isAlphaNum)
    

    iToSql No usage example found for this symbol :( Collapse [-]
    nToSql No usage example found for this symbol :( Collapse [-]
    posixToSql No usage example found for this symbol :( Collapse [-]
    safeFromSql No usage example found for this symbol :( Collapse [-]
    toSql See 2 Occurences [+] Collapse [-]
    Found in Database.YeshQL.HDBC from the package yeshql-hdbc
            then
                rawQueryFunc
                    `appE` (litE . stringL . pqQueryString $ query)
                    `appE` (varE . mkName $ "conn")
            else
                queryFunc
                    `appE` (litE . stringL . pqQueryString $ query)
                    `appE` (listE (map paramArg $ pqParamsRaw query))
                    `appE` (varE . mkName $ "conn")
    
        where
            paramArg :: ExtractedParam -> ExpQ
            paramArg (ExtractedParam n ps _) = do
                let valE = foldl1 (flip appE) (map (varE . mkName) (n:ps))
                varE 'toSql `appE` valE
    

    Found in Database.YeshQL.HDBC from the package yeshql-hdbc
    , parseQuery
    , parseQueries
    -- * AST
    , ParsedQuery (..)
    )
    where
    
    import Language.Haskell.TH
    import Language.Haskell.TH.Quote
    #if MIN_VERSION_template_haskell(2,7,0)
    import Language.Haskell.TH.Syntax (Quasi(qAddDependentFile))
    #endif
    import Data.List (isPrefixOf, foldl')
    import Data.Maybe (catMaybes, fromMaybe)
    import Database.HDBC (fromSql, toSql, run, runRaw, ConnWrapper, IConnection, quickQuery')
    import qualified Text.Parsec as P
    import Data.Char (chr, ord, toUpper, toLower)
    import Control.Applicative ( (<$>), (<*>) )
    import System.FilePath (takeBaseName)
    import Data.Char (isAlpha, isAlphaNum)
    

    SqlValue No usage example found for this symbol :( Collapse [-]
    SqlError No usage example found for this symbol :( Collapse [-]
    Statement No usage example found for this symbol :( Collapse [-]
    withWConn No usage example found for this symbol :( Collapse [-]
    ConnWrapper No usage example found for this symbol :( Collapse [-]
    IConnection No usage example found for this symbol :( Collapse [-]
    catchSql No usage example found for this symbol :( Collapse [-]
    fetchAllRows See 1 Occurences [+] Collapse [-]
    Found in Database.HDBC.Record.Query from the package relational-query-HDBC
    {- $fetchWithLazyIO
    __CAUTION!!__
    
    /Lazy-IO/ APIs may be harmful in complex transaction with RDBMs interfaces
    which require sequential ordered calls of low-level APIs.
     -}
    
    -- | Fetch a record.
    fetch :: FromSql SqlValue a => ExecutedStatement a -> IO (Maybe a)
    fetch =  fetchRecords HDBC.fetchRow
    
    -- | /Lazy-IO/ version of 'fetchAll''.
    fetchAll :: FromSql SqlValue a => ExecutedStatement a -> IO [a]
    fetchAll =  fetchRecords HDBC.fetchAllRows
    
    -- | Strictly fetch all records.
    fetchAll' :: FromSql SqlValue a => ExecutedStatement a -> IO [a]
    fetchAll' =  fetchRecords HDBC.fetchAllRows'
    

    fetchAllRows' See 1 Occurences [+] Collapse [-]
    Found in Database.HDBC.Record.Query from the package relational-query-HDBC
    /Lazy-IO/ APIs may be harmful in complex transaction with RDBMs interfaces
    which require sequential ordered calls of low-level APIs.
     -}
    
    -- | Fetch a record.
    fetch :: FromSql SqlValue a => ExecutedStatement a -> IO (Maybe a)
    fetch =  fetchRecords HDBC.fetchRow
    
    -- | /Lazy-IO/ version of 'fetchAll''.
    fetchAll :: FromSql SqlValue a => ExecutedStatement a -> IO [a]
    fetchAll =  fetchRecords HDBC.fetchAllRows
    
    -- | Strictly fetch all records.
    fetchAll' :: FromSql SqlValue a => ExecutedStatement a -> IO [a]
    fetchAll' =  fetchRecords HDBC.fetchAllRows'
    
    -- | Fetch all records but get only first record.
    --   Expecting result records is unique.
    fetchUnique :: FromSql SqlValue a => ExecutedStatement a -> IO (Maybe a)
    fetchUnique es = do
    

    fetchAllRowsAL No usage example found for this symbol :( Collapse [-]
    fetchAllRowsAL' No usage example found for this symbol :( Collapse [-]
    fetchAllRowsMap No usage example found for this symbol :( Collapse [-]
    fetchAllRowsMap' No usage example found for this symbol :( Collapse [-]
    fetchRowAL No usage example found for this symbol :( Collapse [-]
    fetchRowMap No usage example found for this symbol :( Collapse [-]
    handleSql See 2 Occurences [+] Collapse [-]
    Found in Database.HDBC.Session from the package HDBC-session
    {- $showErrors
    Functions to show 'SqlError' type not to show 'String' fields.
    -}
    
    -- | show 'SqlError' not to show 'String' fields.
    showSqlError :: SqlError -> String
    showSqlError se = unlines
      ["seState: '" ++ seState se ++ "'",
       "seNativeError: " ++ show (seNativeError se),
       "seErrorMsg: '" ++ seErrorMsg se ++ "'"]
    
    -- | Like 'handleSqlError', but not to show 'String' fields of SqlError.
    handleSqlError' :: IO a -> IO a
    handleSqlError' =  handleSql (fail . reformat . showSqlError)  where
      reformat = ("SQL error: \n" ++) . unlines . map ("  " ++) . lines
    
    -- | Generalized session with bracketed HDBC connection.
    --   Run a transaction on a HDBC IConnection and close the connection.
    bracketConnection :: (Monad m, IConnection conn)
    

    Found in Database.HDBC.Session from the package HDBC-session
      withConnectionIO, withConnectionIO_,
    
      bracketConnection,
    
      -- * Show errors
      -- $showErrors
      showSqlError, handleSqlError',
    
      -- * Deprecated
      withConnection,
      withConnectionIO',
      withConnectionCommit,
      ) where
    
    import Database.HDBC (IConnection, handleSql,
                          SqlError(seState, seNativeError, seErrorMsg))
    import qualified Database.HDBC as HDBC
    import Control.Exception (bracket)
    

    handleSqlError No usage example found for this symbol :( Collapse [-]
    quickQuery No usage example found for this symbol :( Collapse [-]
    quickQuery' See 5 Occurences [+] Collapse [-]
    Found in Database.YeshQL.HDBC from the package yeshql-hdbc
                                        [(listP (map (varP . mkName) varNames))]
                                        -- (fromSql a, fromSql b, fromSql c, ...)
                                        (tupE $ (map (\n -> appE (varE 'fromSql) (varE . mkName $ n)) varNames)))|]
                        ReturnRecord _ x -> [|fromSqlRow|]
            queryFunc = case pqReturnType query of
                            ReturnRowCount _ ->
                                [| \qstr params conn -> $convert <$> run conn qstr params |]
                            ReturnTuple Many _ ->
                                [| \qstr params conn -> $convert <$> quickQuery' conn qstr params |]
                            ReturnTuple One _ ->
                                [| \qstr params conn -> fmap headMay $ $convert <$> quickQuery' conn qstr params |]
                            ReturnRecord Many _ ->
                                [| \qstr params conn -> mapM $convert =<< quickQuery' conn qstr params |]
                            ReturnRecord One _ ->
                                [| \qstr params conn -> fmap headMay $ mapM $convert =<< quickQuery' conn qstr params |]
            rawQueryFunc = [| \qstr conn -> runRaw conn qstr |]
        if pqDDL query
            then
                rawQueryFunc
                    `appE` (litE . stringL . pqQueryString $ query)
    

    Found in Database.YeshQL.HDBC from the package yeshql-hdbc
                            in [|map $(lamE
                                        -- \[a,b,c,...] ->
                                        [(listP (map (varP . mkName) varNames))]
                                        -- (fromSql a, fromSql b, fromSql c, ...)
                                        (tupE $ (map (\n -> appE (varE 'fromSql) (varE . mkName $ n)) varNames)))|]
                        ReturnRecord _ x -> [|fromSqlRow|]
            queryFunc = case pqReturnType query of
                            ReturnRowCount _ ->
                                [| \qstr params conn -> $convert <$> run conn qstr params |]
                            ReturnTuple Many _ ->
                                [| \qstr params conn -> $convert <$> quickQuery' conn qstr params |]
                            ReturnTuple One _ ->
                                [| \qstr params conn -> fmap headMay $ $convert <$> quickQuery' conn qstr params |]
                            ReturnRecord Many _ ->
                                [| \qstr params conn -> mapM $convert =<< quickQuery' conn qstr params |]
                            ReturnRecord One _ ->
                                [| \qstr params conn -> fmap headMay $ mapM $convert =<< quickQuery' conn qstr params |]
            rawQueryFunc = [| \qstr conn -> runRaw conn qstr |]
        if pqDDL query
            then
    

    Found in Database.YeshQL.HDBC from the package yeshql-hdbc
                        ReturnTuple _ xs ->
                            let varNames = map nthIdent [0..pred (length xs)]
                            in [|map $(lamE
                                        -- \[a,b,c,...] ->
                                        [(listP (map (varP . mkName) varNames))]
                                        -- (fromSql a, fromSql b, fromSql c, ...)
                                        (tupE $ (map (\n -> appE (varE 'fromSql) (varE . mkName $ n)) varNames)))|]
                        ReturnRecord _ x -> [|fromSqlRow|]
            queryFunc = case pqReturnType query of
                            ReturnRowCount _ ->
                                [| \qstr params conn -> $convert <$> run conn qstr params |]
                            ReturnTuple Many _ ->
                                [| \qstr params conn -> $convert <$> quickQuery' conn qstr params |]
                            ReturnTuple One _ ->
                                [| \qstr params conn -> fmap headMay $ $convert <$> quickQuery' conn qstr params |]
                            ReturnRecord Many _ ->
                                [| \qstr params conn -> mapM $convert =<< quickQuery' conn qstr params |]
                            ReturnRecord One _ ->
                                [| \qstr params conn -> fmap headMay $ mapM $convert =<< quickQuery' conn qstr params |]
            rawQueryFunc = [| \qstr conn -> runRaw conn qstr |]
    

    Found in Database.YeshQL.HDBC from the package yeshql-hdbc
                        ReturnTuple _ [] -> [|\_ -> ()|]
                        ReturnTuple _ (x:[]) -> [|map (fromSql . head)|]
                        ReturnTuple _ xs ->
                            let varNames = map nthIdent [0..pred (length xs)]
                            in [|map $(lamE
                                        -- \[a,b,c,...] ->
                                        [(listP (map (varP . mkName) varNames))]
                                        -- (fromSql a, fromSql b, fromSql c, ...)
                                        (tupE $ (map (\n -> appE (varE 'fromSql) (varE . mkName $ n)) varNames)))|]
                        ReturnRecord _ x -> [|fromSqlRow|]
            queryFunc = case pqReturnType query of
                            ReturnRowCount _ ->
                                [| \qstr params conn -> $convert <$> run conn qstr params |]
                            ReturnTuple Many _ ->
                                [| \qstr params conn -> $convert <$> quickQuery' conn qstr params |]
                            ReturnTuple One _ ->
                                [| \qstr params conn -> fmap headMay $ $convert <$> quickQuery' conn qstr params |]
                            ReturnRecord Many _ ->
                                [| \qstr params conn -> mapM $convert =<< quickQuery' conn qstr params |]
                            ReturnRecord One _ ->
    

    Found in Database.YeshQL.HDBC from the package yeshql-hdbc
    , parseQuery
    , parseQueries
    -- * AST
    , ParsedQuery (..)
    )
    where
    
    import Language.Haskell.TH
    import Language.Haskell.TH.Quote
    #if MIN_VERSION_template_haskell(2,7,0)
    import Language.Haskell.TH.Syntax (Quasi(qAddDependentFile))
    #endif
    import Data.List (isPrefixOf, foldl')
    import Data.Maybe (catMaybes, fromMaybe)
    import Database.HDBC (fromSql, toSql, run, runRaw, ConnWrapper, IConnection, quickQuery')
    import qualified Text.Parsec as P
    import Data.Char (chr, ord, toUpper, toLower)
    import Control.Applicative ( (<$>), (<*>) )
    import System.FilePath (takeBaseName)
    import Data.Char (isAlpha, isAlphaNum)
    

    sExecute No usage example found for this symbol :( Collapse [-]
    sExecuteMany No usage example found for this symbol :( Collapse [-]
    sFetchAllRows No usage example found for this symbol :( Collapse [-]
    sFetchAllRows' No usage example found for this symbol :( Collapse [-]
    sFetchRow No usage example found for this symbol :( Collapse [-]
    sRun No usage example found for this symbol :( Collapse [-]
    sqlExceptions No usage example found for this symbol :( Collapse [-]
    throwSqlError No usage example found for this symbol :( Collapse [-]
    withTransaction No usage example found for this symbol :( Collapse [-]