hasql-backend-0.1.0: API for backends of "hasql"

Safe HaskellNone
LanguageHaskell2010

Hasql.Backend

Description

An open API for implementation of specific backend drivers.

Synopsis

Documentation

data Error Source

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.

type TransactionMode = (IsolationLevel, Bool) Source

An isolation level and a boolean, defining, whether the transaction will perform the "write" operations.

type Stream b = ListT IO (Vector (Result b)) Source

A stream of rows of a result.

type Matrix b = Vector (Vector (Result b)) Source

A matrix of a result.

type Statement b = (ByteString, [StatementArgument b]) Source

A template statement with values for placeholders.

class Backend b where Source

Associated Types

data StatementArgument b Source

An argument prepared for a statement.

data Result b Source

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.