hasql-0.19.18: An efficient PostgreSQL driver and a flexible mapping API

Safe Haskell | None
Language | Haskell2010

Hasql.Connection

Description

This module provides a low-level effectful API dealing with the connections to the database.

Synopsis

- data Connection
- type ConnectionError = Maybe ByteString
- acquire :: Settings -> IO (Either ConnectionError Connection)
- release :: Connection -> IO ()
- type Settings = ByteString
- settings :: ByteString -> Word16 -> ByteString -> ByteString -> ByteString -> Settings
- withLibPQConnection :: Connection -> (Connection -> IO a) -> IO a

# Documentation

data Connection #

A single connection to the database.

type ConnectionError = Maybe ByteString #

Possible details of the connection acquistion error.

acquire :: Settings -> IO (Either ConnectionError Connection) #

Acquire a connection using the provided settings encoded according to the PostgreSQL format.

release :: Connection -> IO () #

Release the connection.

type Settings = ByteString #

All settings encoded in a single byte-string according to the PostgreSQL format.

settings :: ByteString -> Word16 -> ByteString -> ByteString -> ByteString -> Settings #

Encode a host, a port, a user, a password and a database into the PostgreSQL settings byte-string.

withLibPQConnection :: Connection -> (Connection -> IO a) -> IO a #

Execute an operation on the raw `libpq` `Connection`.

The access to the connection is exclusive.