Safe Haskell | None |
---|---|
Language | Haskell2010 |
Hasql.Backend
Description
An open API for implementation of specific backend drivers.
- data Error
- = CantConnect Text
- | ConnectionLost Text
- | ErroneousResult Text
- | UnexpectedResult Text
- | UnparsableTemplate Text
- | TransactionConflict
- | NotInTransaction
- data IsolationLevel
- type TransactionMode = (IsolationLevel, Bool)
- type Stream b = ListT IO (Vector (Result b))
- type Matrix b = Vector (Vector (Result b))
- type Statement b = (ByteString, [StatementArgument b])
- class Backend b where
- data StatementArgument b
- data Result b
- data Connection b
- connect :: b -> IO (Connection b)
- disconnect :: Connection b -> IO ()
- execute :: Statement b -> Connection b -> IO ()
- executeAndGetMatrix :: Statement b -> Connection b -> IO (Matrix b)
- executeAndStream :: Statement b -> Connection b -> IO (Stream b)
- executeAndCountEffects :: Statement b -> Connection b -> IO Word64
- beginTransaction :: TransactionMode -> Connection b -> IO ()
- finishTransaction :: Bool -> Connection b -> IO ()
- class Mapping b v where
- renderValue :: v -> StatementArgument b
- parseResult :: Result b -> Either Text v
Documentation
Constructors
CantConnect Text | Cannot connect to a server. |
ConnectionLost Text | The connection got interrupted. |
ErroneousResult Text | Some kind of error on backend. |
UnexpectedResult Text | An unexpected or an unparsable result. |
UnparsableTemplate Text | An unparsable statement template. |
TransactionConflict | A transaction concurrency conflict, which indicates that it should be retried. |
NotInTransaction | An operation, which requires a database transaction was executed without one. |
data IsolationLevel Source
For reference see the Wikipedia info.
Constructors
Serializable | |
RepeatableReads | |
ReadCommitted | |
ReadUncommitted |
type TransactionMode = (IsolationLevel, Bool) Source
An isolation level and a boolean, defining, whether the transaction will perform the "write" operations.
type Statement b = (ByteString, [StatementArgument b]) Source
A template statement with values for placeholders.
Associated Types
data StatementArgument b Source
An argument prepared for a statement.
A raw value returned from the database.
data Connection b Source
A backend-specific connection.
Methods
connect :: b -> IO (Connection b) Source
Open a connection using the backend's settings.
disconnect :: Connection b -> IO () Source
Close the connection.
execute :: Statement b -> Connection b -> IO () Source
Execute a statement.
executeAndGetMatrix :: Statement b -> Connection b -> IO (Matrix b) Source
Execute a statement and get a matrix of results.
executeAndStream :: Statement b -> Connection b -> IO (Stream b) Source
Execute a statement and stream the results using a cursor. This function will only be used from inside of transactions.
executeAndCountEffects :: Statement b -> Connection b -> IO Word64 Source
Execute a statement, returning the amount of affected rows.
beginTransaction :: TransactionMode -> Connection b -> IO () Source
Start a transaction in the specified mode.
finishTransaction :: Bool -> Connection b -> IO () Source
Finish the transaction,
while releasing all the resources acquired with executeAndStream
.
The boolean defines whether to commit the updates, otherwise it rolls back.
class Mapping b v where Source
Support by a backend of a specific data type.
Methods
renderValue :: v -> StatementArgument b Source
parseResult :: Result b -> Either Text v Source