| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
Hasql.Session
Synopsis
- data Session a
 - sql :: ByteString -> Session ()
 - statement :: params -> Statement params result -> Session result
 - pipeline :: Pipeline result -> Session result
 - run :: Session a -> Connection -> IO (Either SessionError a)
 - data SessionError
 - data CommandError
 - data ResultError
 - data RowError
 
Documentation
A batch of actions to be executed in the context of a database connection.
Instances
| MonadIO Session Source # | |
Defined in Hasql.Session.Core  | |
| Applicative Session Source # | |
| Functor Session Source # | |
| Monad Session Source # | |
| MonadError SessionError Session Source # | |
Defined in Hasql.Session.Core Methods throwError :: SessionError -> Session a # catchError :: Session a -> (SessionError -> Session a) -> Session a #  | |
| MonadReader Connection Session Source # | |
Defined in Hasql.Session.Core Methods ask :: Session Connection # local :: (Connection -> Connection) -> Session a -> Session a # reader :: (Connection -> a) -> Session a #  | |
sql :: ByteString -> Session () Source #
Possibly a multi-statement query, which however cannot be parameterized or prepared, nor can any results of it be collected.
statement :: params -> Statement params result -> Session result Source #
Execute a statement by providing parameters to it.
Execution
run :: Session a -> Connection -> IO (Either SessionError a) Source #
Executes a bunch of commands on the provided connection.
Errors
data SessionError Source #
Error during execution of a session.
Constructors
| QueryError | Error during the execution of a query. Comes packed with the query template and a textual representation of the provided params.  | 
Fields 
  | |
| PipelineError | Error during the execution of a pipeline.  | 
Fields 
  | |
Instances
| Exception SessionError Source # | |
Defined in Hasql.Errors Methods toException :: SessionError -> SomeException # fromException :: SomeException -> Maybe SessionError # displayException :: SessionError -> String # backtraceDesired :: SessionError -> Bool #  | |
| Show SessionError Source # | |
Defined in Hasql.Errors Methods showsPrec :: Int -> SessionError -> ShowS # show :: SessionError -> String # showList :: [SessionError] -> ShowS #  | |
| Eq SessionError Source # | |
Defined in Hasql.Errors  | |
| MonadError SessionError Session Source # | |
Defined in Hasql.Session.Core Methods throwError :: SessionError -> Session a # catchError :: Session a -> (SessionError -> Session a) -> Session a #  | |
data CommandError Source #
An error of some command in the session.
Constructors
| ClientError (Maybe ByteString) | An error on the client-side, with a message generated by the "libpq" library. Usually indicates problems with connection.  | 
| ResultError ResultError | Some error with a command result.  | 
Instances
| Show CommandError Source # | |
Defined in Hasql.Errors Methods showsPrec :: Int -> CommandError -> ShowS # show :: CommandError -> String # showList :: [CommandError] -> ShowS #  | |
| Eq CommandError Source # | |
Defined in Hasql.Errors  | |
data ResultError Source #
An error with a command result.
Constructors
| ServerError | An error reported by the DB.  | 
Fields 
  | |
| UnexpectedResult Text | The database returned an unexpected result. Indicates an improper statement or a schema mismatch.  | 
| RowError Int Int RowError | An error of the row reader, preceded by the indexes of the row and column.  | 
| UnexpectedAmountOfRows Int | An unexpected amount of rows.  | 
Instances
| Show ResultError Source # | |
Defined in Hasql.Errors Methods showsPrec :: Int -> ResultError -> ShowS # show :: ResultError -> String # showList :: [ResultError] -> ShowS #  | |
| Eq ResultError Source # | |
Defined in Hasql.Errors  | |
An error during the decoding of a specific row.
Constructors
| EndOfInput | Appears on the attempt to parse more columns than there are in the result.  | 
| UnexpectedNull | Appears on the attempt to parse a   | 
| ValueError Text | Appears when a wrong value parser is used. Comes with the error details.  |