| Copyright | (c) Ole Krüger 2015-2016 |
|---|---|
| License | BSD3 |
| Maintainer | Ole Krüger <ole@vprsm.de> |
| Safe Haskell | None |
| Language | Haskell2010 |
Database.PostgreSQL.Store.Errand
Contents
Description
- data ErrandError
- data ErrorCode
- data ExecStatus :: *
- data Errand a
- runErrand :: Connection -> Errand a -> IO (Either ErrandError a)
- execute :: Query -> Errand Result
- query :: Result a => Query -> Errand [a]
- query_ :: Query -> Errand ()
- queryWith :: Query -> ResultProcessor a -> Errand [a]
- class Result a where
- newtype Single a = Single {
- fromSingle :: a
Errand
data ErrandError Source #
Error during errand
Constructors
| NoResult | No |
| EmptyResult | Result set is empty. |
| UserError String | A user has thrown an error. |
| ExecError ExecStatus ErrorCode ByteString ByteString ByteString | Query execution failed. |
| ResultError ResultError | Result processing failed. |
Instances
Error codes
data ExecStatus :: * #
Constructors
| EmptyQuery | The string sent to the server was empty. |
| CommandOk | Successful completion of a command returning no data. |
| TuplesOk | Successful completion of a command returning data (such as a SELECT or SHOW). |
| CopyOut | Copy Out (from server) data transfer started. |
| CopyIn | Copy In (to server) data transfer started. |
| BadResponse | The server's response was not understood. |
| NonfatalError | A nonfatal error (a notice or warning) occurred. |
| FatalError | A fatal error occurred. |
| SingleTuple | The PGresult contains a single result tuple from the current command. This status occurs only when single-row mode has been selected for the query. |
Instances
An interaction with the database
runErrand :: Connection -> Errand a -> IO (Either ErrandError a) Source #
Run an errand.
queryWith :: Query -> ResultProcessor a -> Errand [a] Source #
Execute a query and process its result set using the provided result processor.
Result parser
Allows you to implement a custom result parser for your type.
mkTable can implement this for your type.
Minimal complete definition
Methods
Instances
| Column a => Result (Single a) Source # | |
| Result (Reference a) Source # | |
| (Result a, Result b) => Result (a, b) Source # | Combine result parsers sequencially. |
| (Result a, Result b, Result c) => Result (a, b, c) Source # | |
| (Result a, Result b, Result c, Result d) => Result (a, b, c, d) Source # | |
| (Result a, Result b, Result c, Result d, Result e) => Result (a, b, c, d, e) Source # | |
| (Result a, Result b, Result c, Result d, Result e, Result f) => Result (a, b, c, d, e, f) Source # | |
| (Result a, Result b, Result c, Result d, Result e, Result f, Result g) => Result (a, b, c, d, e, f, g) Source # | |