postgresql-typed- PostgreSQL interface with compile-time SQL type checking, optional HDBC backend

Copyright2016 Dylan Simon
Safe HaskellNone



Use postgresql-typed as a backend for HDBC.



data Connection Source #

A wrapped PGConnection. This differs from a bare PGConnection in a few ways:

  1. It always has exactly one active transaction (with pgBegin)
  2. It automatically disconnects on GC
  3. It provides a mutex around the underlying PGConnection for thread-safety

connect :: PGDatabase -> IO Connection Source #

Connect to a database for HDBC use (equivalent to pgConnect and pgBegin).

fromPGConnection :: PGConnection -> IO Connection Source #

Convert an existing PGConnection to an HDBC-compatible Connection. The caveats under connectionPG apply if you plan to continue using the original PGConnection.

withPGConnection :: Connection -> (PGConnection -> IO a) -> IO a Source #

Use the underlying PGConnection directly. You must be careful to ensure that the first invariant is preserved: you should not call pgBegin, pgCommit, or pgRollback on it. All other operations should be safe.

reloadTypes :: Connection -> IO Connection Source #

Reload the table of all types from the database. This may be needed if you make structural changes to the database.

connectionFetchSize :: Connection -> Word32 Source #

Number of rows to fetch (and cache) with execute and each time fetchRow requires more rows. A higher value will result in fewer round-trips to the database but potentially more wasted data. Defaults to 1. 0 means fetch all rows.

setFetchSize :: Word32 -> Connection -> Connection Source #

Change the connectionFetchSize for new Statements created with prepare. Ideally this could be set with each call to execute and fetchRow, but the HDBC interface provides no way to do this.