Copyright | 2013 Kei Hibino |
---|---|
License | BSD3 |
Maintainer | ex8k.hibino@gmail.com |
Stability | experimental |
Portability | unknown |
Safe Haskell | None |
Language | Haskell2010 |
This module provides typed Query
running sequence
which intermediate structres are typed.
- type PreparedQuery p a = PreparedStatement p a
- prepare :: IConnection conn => conn -> Query p a -> IO (PreparedQuery p a)
- prepareQuery :: IConnection conn => conn -> Query p a -> IO (PreparedQuery p a)
- withPrepareQuery :: IConnection conn => conn -> Query p a -> (PreparedQuery p a -> IO b) -> IO b
- fetch :: FromSql SqlValue a => ExecutedStatement a -> IO (Maybe a)
- fetchAll :: FromSql SqlValue a => ExecutedStatement a -> IO [a]
- fetchAll' :: FromSql SqlValue a => ExecutedStatement a -> IO [a]
- listToUnique :: [a] -> IO (Maybe a)
- fetchUnique :: FromSql SqlValue a => ExecutedStatement a -> IO (Maybe a)
- fetchUnique' :: FromSql SqlValue a => ExecutedStatement a -> IO (Maybe a)
- runStatement :: FromSql SqlValue a => BoundStatement a -> IO [a]
- runStatement' :: FromSql SqlValue a => BoundStatement a -> IO [a]
- runPreparedQuery :: (ToSql SqlValue p, FromSql SqlValue a) => PreparedQuery p a -> p -> IO [a]
- runPreparedQuery' :: (ToSql SqlValue p, FromSql SqlValue a) => PreparedQuery p a -> p -> IO [a]
- runQuery :: (IConnection conn, ToSql SqlValue p, FromSql SqlValue a) => conn -> Query p a -> p -> IO [a]
- runQuery' :: (IConnection conn, ToSql SqlValue p, FromSql SqlValue a) => conn -> Query p a -> p -> IO [a]
Documentation
type PreparedQuery p a = PreparedStatement p a Source
Typed prepared query type.
:: IConnection conn | |
=> conn | Database connection |
-> Query p a | Typed query |
-> IO (PreparedQuery p a) | Result typed prepared query with parameter type |
Typed prepare query operation.
:: IConnection conn | |
=> conn | Database connection |
-> Query p a | Typed query |
-> IO (PreparedQuery p a) | Result typed prepared query with parameter type |
Same as prepare
.
:: IConnection conn | |
=> conn | Database connection |
-> Query p a | Typed query |
-> (PreparedQuery p a -> IO b) | Body action to use prepared statement |
-> IO b | Result action |
Bracketed prepare operation.
listToUnique :: [a] -> IO (Maybe a) Source
Fetch expecting result records is unique.
fetchUnique :: FromSql SqlValue a => ExecutedStatement a -> IO (Maybe a) Source
Fetch all records but get only first record. Expecting result records is unique.
fetchUnique' :: FromSql SqlValue a => ExecutedStatement a -> IO (Maybe a) Source
Fetch all records but get only first record. Expecting result records is unique. Error when records count is more than one.
runStatement :: FromSql SqlValue a => BoundStatement a -> IO [a] Source
Execute statement and lazily fetch all records.
runStatement' :: FromSql SqlValue a => BoundStatement a -> IO [a] Source
Strict version of runStatement
.
:: (ToSql SqlValue p, FromSql SqlValue a) | |
=> PreparedQuery p a | Statement to bind to |
-> p | Parameter type |
-> IO [a] | Action to get records |
Bind parameters, execute statement and lazily fetch all records.
:: (ToSql SqlValue p, FromSql SqlValue a) | |
=> PreparedQuery p a | Statement to bind to |
-> p | Parameter type |
-> IO [a] | Action to get records |
Strict version of runPreparedQuery
.